Path: news.mathworks.com!not-for-mail
From: "Phil " <harsh_classic@yahoo.co.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Ignoring an empty array
Date: Wed, 1 Apr 2009 14:26:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <gqvthp$q2c$1@fred.mathworks.com>
References: <gqvnkf$5q8$1@fred.mathworks.com> <gqvsc9$9kk$1@fred.mathworks.com>
Reply-To: "Phil " <harsh_classic@yahoo.co.uk>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1238595961 26700 172.30.248.38 (1 Apr 2009 14:26:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Apr 2009 14:26:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1633247
Xref: news.mathworks.com comp.soft-sys.matlab:529387


"Jos " <#10584@fileexchange.com> wrote in message <gqvsc9$9kk$1@fred.mathworks.com>...
> "Phil " <harsh_classic@yahoo.co.uk> wrote in message <gqvnkf$5q8$1@fred.mathworks.com>...
> > Hi there.
> > 
> > Here is my problem. I have 3 arrays, 2 full and one empty in the format below
> > 
> > [15x1 double]    [0x1 double]    [24x1 double]
> > 
> > 1.) How can i ignore the empty array
> > 
> > 2.) But still recognise the order it is in i.e. [15x1 double] = 1st place, [0x1 double] = 2nd place and [24x1 double] = 3rd place.
> > 
> > Can anyone help?
> > 
> > Thanks in advance,
> > 
> > Phil
> 
> Are these arrays stored in a cell array? A lazy suggestion could be:
> 
> % data
> C = {[1 2 3],[],[6 7 8 9 10]}
> 
> % create a place vector
> place = C ;
> for i=1:numel(C),
>  t = place{i} ;
>  t(:) = i ;
>  place{i} = t ;
> end
> Result = [place{:} ; C{:}]
> 
> More matlab-like alternatives could include cellfun, cell2struct etc. But it depends on what you need to do exactly, and what you mean by "ignore the empty array"?
> 
> hth
> Jos

Hi Jos,

Many thanks for your help. I have managed to sort it now.

Kind regards,

Phil