Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k26g2000vbp.googlegroups.com!not-for-mail
From: arun <aragorn168b@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: cell array
Date: Fri, 23 Oct 2009 01:51:34 -0700 (PDT)
Organization: http://groups.google.com
Lines: 36
Message-ID: <88d1454a-532d-4479-b540-c55fcbfc9c97@k26g2000vbp.googlegroups.com>
References: <hbrp39$me3$1@fred.mathworks.com>
NNTP-Posting-Host: 134.2.162.99
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1256287894 20771 127.0.0.1 (23 Oct 2009 08:51:34 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 23 Oct 2009 08:51:34 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k26g2000vbp.googlegroups.com; posting-host=134.2.162.99; 
	posting-account=fyqXpgoAAABqt-0BifyaNxmZhzggFACu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-us) 
	AppleWebKit/531.9 (KHTML, like Gecko) NetNewsWire/3.2.1,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:579520


On Oct 23, 10:22 am, "sujata " <sujat...@gmail.com> wrote:
> 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?
>
> Thanks

help cell2mat

but the problem is that if your cell has [] in both the columns, the
entry will be eliminated. I suggest you just replace the empty values
with 0's and then convert using cell2mat and perform the operations
and then convert back to cell if necessary...

but, if all your values are cell, then why go for cell? it just takes
up more space..

best, arun.