[Fwd: Re: Loop over cell arrays.]

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Fwd: Re: Loop over cell arrays.]

Paul Thomas-10
This goes in Matlab 5

mycell = { 'foo' , 1.0 , 'bar' };
for tmp = mycell ; disp( tmp ) ; end ;

but gives "error: invalid type for loop expression near .." in octave-2.1.57

Another for the "todo" list?

Paul T

version returns 2.1.36

thanx again, I'll upgrade later tonight.

-----Original Message-----
From: John W. Eaton [mailto:[hidden email]]
Sent: Thursday, August 26, 2004 2:40 PM
To: Sean Smith
Cc: 'Hall, Benjamin'; '[hidden email]'
Subject: RE: Loop over cell arrays.


On 26-Aug-2004, Sean Smith <[hidden email]> wrote:

| length(data)
| ans = -1
|
| that's my problem.
|
| size(data)
| ans =
|
|   -1  -1
|
| nothing seems to access the dimensions of this thing.

What version of Octave are you using?  It seems to work correctly with
the current recommended version, 2.1.57:

  octave:1> x = {"foo", 1, "bar"};
  octave:2> size (x)
  ans =

    1  3

  octave:3> length (x)
  ans = 3

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


Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Re: Loop over cell arrays.]

David Bateman-3
Daprès Paul Thomas <[hidden email]> (le 27/08/2004):
> This goes in Matlab 5
>
> mycell = { 'foo' , 1.0 , 'bar' };
> for tmp = mycell ; disp( tmp ) ; end ;
>
> but gives "error: invalid type for loop expression near .." in octave-2.1.57
>
> Another for the "todo" list?

In octave CVS

octave:1> mycell = { 'foo' , 1.0 , 'bar' };
octave:2> for tmp = mycell ; disp( tmp ) ; end ;
{
  [1,1] = foo
}
{
  [1,1] = 1
}
{
  [1,1] = bar
}

So its not for the todo list, its on the done list....

D.

--
David Bateman                                [hidden email]
Motorola CRM                                 +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary


Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Re: Loop over cell arrays.]

Paul Thomas-10
Ah, great!  I thought that I had seen it on the mailing list.

Paul

----- Original Message -----
From: "David Bateman" <[hidden email]>
To: "Paul Thomas" <[hidden email]>
Cc: "octave maintainers mailing list" <[hidden email]>
Sent: Friday, August 27, 2004 9:39 AM
Subject: Re: [Fwd: Re: Loop over cell arrays.]


> Daprès Paul Thomas <[hidden email]> (le 27/08/2004):
> > This goes in Matlab 5
> >
> > mycell = { 'foo' , 1.0 , 'bar' };
> > for tmp = mycell ; disp( tmp ) ; end ;
> >
> > but gives "error: invalid type for loop expression near .." in
octave-2.1.57

> >
> > Another for the "todo" list?
>
> In octave CVS
>
> octave:1> mycell = { 'foo' , 1.0 , 'bar' };
> octave:2> for tmp = mycell ; disp( tmp ) ; end ;
> {
>   [1,1] = foo
> }
> {
>   [1,1] = 1
> }
> {
>   [1,1] = bar
> }
>
> So its not for the todo list, its on the done list....
>
> D.
>
> --
> David Bateman                                [hidden email]
> Motorola CRM                                 +33 1 69 35 48 04 (Ph)
> Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax)
> 91193 Gif-Sur-Yvette FRANCE
>
> The information contained in this communication has been classified as:
>
> [x] General Business Information
> [ ] Motorola Internal Use Only
> [ ] Motorola Confidential Proprietary