[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating a tabular - maybe using cell ?
From: |
Jaroslav Hajek |
Subject: |
Re: Creating a tabular - maybe using cell ? |
Date: |
Tue, 5 Oct 2010 20:14:55 +0200 |
On Tue, Oct 5, 2010 at 4:55 PM, AlbFrigerio
<address@hidden> wrote:
>
> Hello everyone, I'm trying to use cells to create something like a tabular,
> but I cannot reach it. Here it is my problem, I've got a tabular whose lines
> are of the form [string string float float integer float] , which is updated
> in a for loop.
>
> I'd like to create in Octave something like a tabular representing my input,
> so that I can add a line or access - for example - all the elements in the
> first column by typing tabular{:,1} .
>
> I tried to make something like
>
> a={}; # a = cell(0,6);
> for i=1:5
> b={"hello","world",.1 .2 3 .4};
> a={a;b};
> end
>
You probably want
a = [a;b];
but in general the fastest method will be to either allocate a in
advance or, if the numer of rows is not known, accumulate rows in an
extra array using a{end+1} = b and then do a = vertcat (a{:}) at the
end.
Note that by "fastest" I normally mean the latest development version;
the stable version may give you a diametrally different (and usually
worse) performance.
hth