[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lists and cell arrays ?
From: |
John W. Eaton |
Subject: |
lists and cell arrays ? |
Date: |
Tue, 18 Nov 2003 09:14:52 -0600 |
On 18-Nov-2003, Michael Creel <address@hidden> wrote:
| Question 1:
| what's the best way to do something like
|
| a = 2;
| b = rand(2,1);
| c = list(a,b);
|
| using cell arrays? As far as I can see you need to something like
| a = 2;
| b = rand(2,1)l
| c = cell(2,1);
| c(1) = a;
| c(2) = b;
Or you can write
a = ...;
b = ...;
c = {a, b};
Soon (hopefully 2.1.52) you will also be able to write
c = [c1, c2];
to concatentate two cell arrays.
| Question 2:
| When one extracts a piece of a cell, the result is a cell, e.g.,
|
| a = rand(2,1);
| b = cell(1);
| b(1) = a;
| a = b(1); # here, a is now a cell that contains a 2x1 vector.
| c = rand(2,1);
| a'*c; # this fails - a is a 1x1 cell, and c is a 2x1 vector
You want to use {} indexing:
a = b{1}; # here, a is now a 2x1 vector.
BTW, I'm glad to see that people are trying 2.1.51 as the N-d array
code could use some extra testing, but if you should not be surprised
to find some problems. OTOH, I hope to be fixing most reported
problems fairly quickly and make new snapshots available with those
fixes in a relatively short period of time.
Thanks,
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- lists and cell arrays ?, Michael Creel, 2003/11/18
- lists and cell arrays ?,
John W. Eaton <=
- Re: lists and cell arrays ?, David Bateman, 2003/11/18
- Re: lists and cell arrays ?, taltman, 2003/11/19
- Re: lists and cell arrays ?, John W. Eaton, 2003/11/19
- Re: lists and cell arrays ?, taltman, 2003/11/19
- Re: lists and cell arrays ?, John W. Eaton, 2003/11/19
- Re: lists and cell arrays ?, taltman, 2003/11/19
- Re: lists and cell arrays ?, taltman, 2003/11/19
- Re: lists and cell arrays ?, David Bateman, 2003/11/20