|
"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
|