Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Ignoring an empty array
Date: Wed, 1 Apr 2009 14:06:02 +0000 (UTC)
Organization: Erasmus MC
Lines: 35
Message-ID: <gqvsc9$9kk$1@fred.mathworks.com>
References: <gqvnkf$5q8$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1238594762 9876 172.30.248.38 (1 Apr 2009 14:06:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Apr 2009 14:06:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:529380


"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