help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Appending to a cell string array


From: Søren Hauberg
Subject: Re: Appending to a cell string array
Date: Wed, 09 Feb 2011 17:46:46 +0100

ons, 09 02 2011 kl. 10:36 -0600, skrev Jordi Gutiérrez Hermoso:
> Suppose I have two cell string arrays, x and y, and the strings in x
> and y may be of differing lengths. How can I get a larger array z with
> a linear index from 1 to length(x)+length(y)? I don't want the cell
> arrays to nest.

I'm not sure if this is what you want:

        x = {"Hello", "World"}; y = {"GNU", "is", "not", "Unix"};
        solution1 = cat (2, x, y);
        solution2 = {x{:}, y{:}};

both approaches gives me
        
        {
          [1,1] = Hello
          [1,2] = World
          [1,3] = GNU
          [1,4] = is
          [1,5] = not
          [1,6] = Unix
        }

Søren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]