[Top][All Lists]

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

variable length arrays to be inserted into a single list.

From: Kharidehal Lakshmi A
Subject: variable length arrays to be inserted into a single list.
Date: Thu, 7 Oct 1999 15:53:22 -0500 (CDT)

i have 2 doubts in octave.if u know the answer please mail me back.

1) Suppose I have N variable length arrays:

[ 1 4 5]
[ 3 ]
[ 4 76 89]
[ 3 56 ]
[ 87 4 32  3 ]

I want to put these arrays in a bigger data structure, so that I can 
retrieve any of these arrays when I need them. For this I want to use an 
index. For example, if we were using language C++, it would be:

int **list;

list = new list[N];     // N pointers to arrays

for (int i=0; i<N; i++) {
   list[i] = myCustomList(i);

where the function myCustomList() returns type int* (an integer array) of 
variable size. Of course in this program we will also need to store the 
length of the arrays somewhere. Otherwise I won't be able to know how 
many elements are stored in list[i] for any i. (MATLAB knows the length 
of arrays so I didn't need to store it.)

Now, to have the same functionality in MATLAB, I can use the following 

list = { [2 3 5], [ 4 ], [54 545 6 66 ], [], .... , [3 ], [23 34 5] };

where list(1) will be [ 2 3 5 ] and list(2) will be [ 4 ].

I don't know how to do this in Octave. Octave doesn't have the {} 
operators (in MATLAB they are called 'cell structures').

2) the second question is
the switch structure in matlab doesn't recognise the value
of the case expression to be a string,it considers it to be a matrix
of length equal to the length of the string and gives us an error.
how do u use it.

please mail to me at address@hidden as early as possible.

thanks very much


Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see
Instructions for unsubscribing:

reply via email to

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