find index of empty field in a structure array, vectoried

find index of empty field in a structure array, vectoried

Post by wsun » Sat, 02 Dec 2000 04:00:00



Hello,
let
        x(1).a = 1; x(2).a =[];x(3).a=[];x(4).a=3.4
I would like to get an index array returned to indicate location of
empty element. for this example,
        indx = [0 1 1 0];

Is there an one liner for this?

--wsun

 
 
 

find index of empty field in a structure array, vectoried

Post by Ghassan Hamarne » Sun, 03 Dec 2000 12:05:43


Here you go:

%---
x(1).a = 1; x(2).a =[]; x(3).a =[]; x(4).a = 3.4;
cellfun('isempty',{x.a})
%---

Ghassan


> Hello,
> let
> x(1).a = 1; x(2).a =[];x(3).a=[];x(4).a=3.4
> I would like to get an index array returned to indicate location of
> empty element. for this example,
> indx = [0 1 1 0];

> Is there an one liner for this?

> --wsun


 
 
 

find index of empty field in a structure array, vectoried

Post by wsun » Tue, 05 Dec 2000 04:00:00


Ghassan:
Thank you very much. It's what I needed.

--wsun


> Here you go:

> %---
> x(1).a = 1; x(2).a =[]; x(3).a =[]; x(4).a = 3.4;
> cellfun('isempty',{x.a})
> %---

> Ghassan


> > Hello,
> > let
> > x(1).a = 1; x(2).a =[];x(3).a=[];x(4).a=3.4
> > I would like to get an index array returned to indicate location of
> > empty element. for this example,
> > indx = [0 1 1 0];

> > Is there an one liner for this?

> > --wsun