I have a struct of 283 Area values and I want to copy the higher than 1000 values to a second struct with a for function. I have writen the code I need like this
Lbp = regionprops(Lblack, 'Area');
Lbp.Area;
[r,c]=size(Lbp);
B(r,c) = struct();
for d=1:r
for g=1:c
if Lbp(d).Area > 1000
i=1;
B(i)=Lbp(d);
i=i+1;
end
end
end
I am getting this error Subscripted assignment between dissimilar structures. Even though the structs are the same size. I know that my syntax is wrong but I can not figure out how to syntax it in order to copy the fields to the second struct.
It's because B
and Lbp
do not have the same fields. Try the following:
B(r,c) = struct('Area',[]);