Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newsfeed.ision.net!newsfeed2.easynews.net!ision!citadel.nobulus.com!News.Dal.Ca!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: deleting 0s from an array
Date: Thu, 16 Aug 2007 02:42:24 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 19
Message-ID: <fa0dig$a0h$1@canopus.cc.umanitoba.ca>
References: <fa07po$f1c$1@fred.mathworks.com> <fa08s1$r4b$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1187232144 10257 192.70.172.160 (16 Aug 2007 02:42:24 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Thu, 16 Aug 2007 02:42:24 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:424089


In article <fa08s1$r4b$1@fred.mathworks.com>, us  <us@neurol.unizh.ch> wrote:
>James:
><SNIP no-zeros, please, evergreen...

>>   Is there any easy way to delete all zero values from an 
>array...

>one of the copious solutions

>% the data
>     d=[0,0,0,1,0,0,0,2,0,0,0,3]
>% ...without zeros
>     d(d==0)=[]

I can "golf" that!

d(~d)=[]    %provided d does not contain a nan
-- 
  If you lie to the compiler, it will get its revenge. -- Henry Spencer