help-octave
[Top][All Lists]
Advanced

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

Re: Getting a character matrix out of a cell array "column"?


From: Jaroslav Hajek
Subject: Re: Getting a character matrix out of a cell array "column"?
Date: Wed, 10 Mar 2010 18:09:43 +0100

On Wed, Mar 10, 2010 at 3:52 PM, forkandwait <address@hidden> wrote:
> Hi all,
>
> So I read in a csv file with two columns, the first being, say, the name of a
> person the second her height, along with a header row ("name,height").
>
> stuff = csv2cell('blah.csv')
>

When asking questions on this list, it's better to avoid referring to
functions that are not part of Octave. I don't exactly know what
csv2cell does, although the name seems quite descriptive.

> To get the column of heights sans header, I do this:
>
> h = [stuff{2:end,2}]'
>
> h is now:
>
> 1.8
> 1.8
> 1.9
>
> etc.
>
> How do I get a similar thing for the text column?  I don't mind each row being
> truncated to a certain pre-determined column width, though having the max 
> width
> calculated would be better.  Thus
>
> names:
>
> Mary
> Frances
> Cecilia
>
> etc
>
> Thanks!
>

You probably want
char (stuff(2:end, 1));

Note that depending on what you intend to do with the list, keeping it
as a cell array may be more suitable.

hth

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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