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: bpabbott
Subject: Re: Appending to a cell string array
Date: Wed, 09 Feb 2011 17:27:45 +0000 (GMT)

On Feb 09, 2011, at 11:46 AM, Søren Hauberg <address@hidden> wrote:

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
 
Or solution3

octave:1> x = {"Hello", "World"}; y = {"GNU", "is", "not", "Unix"};
octave:2> [x, y]
ans = 
{
  [1,1] = Hello
  [1,2] = World
  [1,3] = GNU
  [1,4] = is
  [1,5] = not
  [1,6] = Unix
}

Ben



reply via email to

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