Path: news.mathworks.com!not-for-mail
From: "sujata " <sujatagp@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: cell array
Date: Fri, 23 Oct 2009 09:34:20 +0000 (UTC)
Organization: AEGON Nederland N.V.
Lines: 44
Message-ID: <hbrtas$l5f$1@fred.mathworks.com>
References: <hbrp39$me3$1@fred.mathworks.com> <hbrr50$gfq$1@fred.mathworks.com> <hbrs8j$6h3$1@fred.mathworks.com>
Reply-To: "sujata " <sujatagp@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256290460 21679 172.30.248.35 (23 Oct 2009 09:34:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Oct 2009 09:34:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1683215
Xref: news.mathworks.com comp.soft-sys.matlab:579533


The reason that the cell is used is because I draw the data from a database and it puts it automatically into an cell array since it consists of numeric and strings.
But then i select only the columns which I need and incidentally this is the data.

That's why i am trying to filter out the cell. 

Thanks for the ideas

"Branko " <bogunovic@mbss.org> wrote in message <hbrs8j$6h3$1@fred.mathworks.com>...
> "Vinayagam " <bkvinay2001@yahoo.com> wrote in message <hbrr50$gfq$1@fred.mathworks.com>...
> > Try this one,
> > 
> > [Z{:,1}]'-[Z{:,2}]'.
> > 
> > --
> > Vinayagam.
> > 
> > "sujata " <sujatagp@gmail.com> wrote in message <hbrp39$me3$1@fred.mathworks.com>...
> > > I have a 5 by 2 cell array that is only filled with numbers. Something like this:
> > > Z = 
> > >    [ 1.6168]    [ 0.8652]
> > >     [ 0.5724]    [ 0.2323]
> > >     [ 2.5916]    [ 2.6805]
> > >     [-5.1700]    [      0]
> > >     [ 1.4836]    [ 0.4542]
> > >     [-0.1367]    [      0]
> > >     [ 2.5100]    [ 2.9110]
> > >            []           []
> > >     [ 1.7531]    [ 1.7531]
> > >     [-0.6462]    [-0.6462]
> > > 
> > > but i want to take the difference between these two columns. Since it is an cell array this is not possible to simply do Z(:,1)-Z(:,2).
> > > 
> > > I could use a for loop but i want to avoid using that. I also looked in the documentation for cell conversions but so far no luck. 
> > > 
> > > Does anyone know (if) there is an alternative way to do this?
> > > 
> 
> Why do you need cell array? If you have mix type of data (string,numeric) or different size of arrays is good otherwise as, Arun mentioned transform to matrix and do your operation. 
> 
> Moreover, be careful about empty cells - replace them with NaN and NOT 0 since this represents number!
> 
> Very useful function to look is bsxfun.
> 
> Branko