[Top][All Lists]

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

Conversion of numeric cell arrays or cs-lists into normal arrays

From: Francisco Jesús Martínez Serrano
Subject: Conversion of numeric cell arrays or cs-lists into normal arrays
Date: Wed, 27 Dec 2006 15:34:02 +0100


lately I've been using cell arrays to hold structs. Since the structs are uniform (all of them have the same fields), I thought of shifting to struct arrays and be able to traverse the structures and get an array with a value corresponding to each structure by using the . indexing operator.


ans =

  [1] =  2.5317e+11
  [2] =  1.3210e+11
  [3] =  7.3433e+10

Here s0 is the struct array. Each struct in s0 has a member called m

The resulting type of object is of type cs-list. Now I want to make a plot of s0.m against, say, s0.v

the plot function shows no error but the resulting plot has no lines, just a lengend for 3 lines.

Matlab documentation says you should use a for loop to convert between a cell array (which i can obtain with { s0.m}).

I was wondering if there is any way in octave to do this in a more direct fashion.

I don't even know if the problem is well posed, but it would make the whole concept of struct arrays much more useful. I believe the main advantage of struct arrays is being able to index them as if they were structs and get "something", a cs-list. If a cs-list is made out of simple scalars, it should be trivial to convert it to a matrix.

If {s0.m} gives me a cell array, then [s0.m] should give an array.

I guess I could try to implement this myself on octave, but I don't know if there's a point, maybe a solution already exists and I'm too ignorant :-)

Any ideas?

reply via email to

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