help-octave
[Top][All Lists]
Advanced

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

Re: 'for' loop on elements of cell array (octave-3.4.2) - is it the way


From: John W. Eaton
Subject: Re: 'for' loop on elements of cell array (octave-3.4.2) - is it the way it is supposed to be ?
Date: Thu, 2 Feb 2012 12:20:37 -0500

On  2-Feb-2012, Sergei Steshenko wrote:

| > Do you see now why the columns must be extracted as cells, not the
| > individual cell elements?
| > 
| > jwe
| 
| Well, maybe. The code produces:
| 
| "
| octave:1> cell_array = {[1,2;3,4], "foobar"; [5,6], {7, "foo", [8,9,10]}};
| octave:2>
| octave:2>   for elt = cell_array
| >     elt
| >   endfor
| elt =
| {
|   [1,1] =
| 
|      1   2
|      3   4
| 
|   [2,1] =
| 
|      5   6
| 
| }
| elt =
| {
|   [1,1] = foobar
|   [2,1] =
|   {
|     [1,1] =  7
|     [1,2] = foo
|     [1,3] =
| 
|         8    9   10
| 
|   }
| }
| octave:3>     
| "
| 
| and it can make sense to me if I consider cell array to be a 2D matrix with 
possibly  "awkward" (arbitrary type) elements.
| 
| Should cell arrays be considered as 2D matrices ? If yes, which part of 
Octave documentation describes them as such ?

http://www.gnu.org/software/octave/doc/interpreter/Cell-Arrays.html#Cell-Arrays

jwe


reply via email to

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