help-octave
[Top][All Lists]
Advanced

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

Re: An array of arrays?


From: Henry F. Mollet
Subject: Re: An array of arrays?
Date: Tue, 02 Nov 2004 15:59:46 -0800
User-agent: Microsoft-Entourage/10.1.1.2418

I'm beginning to understand what a cell array is about. Assume that I
constructed a large cell array and that I forgot one item. How do I squeeze
in an additional item at a specified location, say between a{2} and a{3} in
the example below without starting from scratch and a{3} will become a{4}?

Also, if
octave:42> a{3}
ans = string
Why is 
octave:41> a{[3,1]}
ans =
(
  [1] = string
  [2] = 1
)

Henry



on 11/1/04 6:23 AM, Quentin Spencer at address@hidden wrote:

> I think a cell array is what you're looking for. Each element of a cell
> array can have a different type and different dimensions. Cell arrays
> are indexed using {}. For example:
> 
> octave:1> a{1} = 1;
> octave:2> a{2} = [1,1,1];
> octave:3> a{3} = "string";
> octave:4> a
> a =
> 
> {
>  [1,1] = 1
>  [1,2] =
> 
>          1        1        1
> 
>  [1,3] = string
> }
> 
> I hope this helps.
> 
> Quentin
> 
> 
> 
> Vic Norton wrote:
> 
>> Here is my problem. I have a subroutine
>>    [X, S] = solsp(rtns, rtn0, noshort)
>> that produce a k x n matrix, X, and a k x 1 matrix, S, from a given m
>> x n matrix, rtns, an m x 1 matrix rtn0, and a (possibly empty)
>> submatrix, noshort, of [1 : n]. The integers m and n are fixed, but k,
>> the number of rows of X and S, varies, depending on the data matrices
>> rtns and rtn0.
>> 
>> The matrices rtns and rtn0 are actually samples of historical returns
>> on certain investments ending at a certain week. I would like to run
>> through a bunch of end-weeks (wk = 1, 2, ..., N) and collect and save
>> the corresponding [X, S] output. The natural data structure would be a
>> list [X(wk), S(wk)] (wk = 1, 2, ..., N) of pairs of arrays of varying
>> row dimensions, k(wk) (wk = 1, 2, ..., N). Is there any reasonably
>> efficient way to create and save such a data structure in Octave?
>> 
>> Note, all arrays contain floating point numbers except for the fixed
>> integer array noshort.
>> 
>> Any ideas would be greatly appreciated.
>> 
>> Regards,
>> 
>> Vic Norton
>> 
> 
> 
> 
> 
> 
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
> 



-------------------------------------------------------------
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 via email to

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