I have some structure arrays (like structure1, structure2, structure3,...) with similar field names. I want to scan through all the structures and return only those whose first field is 5 (Field1==5). I have this code so far,
for k=1:3
s=sprintf('Structure%d',k)
Structure=load(s)
idx=cellfun(@(x) x==5, {Structure.Field1})
out=Structure(idx)
v{k}={Structure.Field1}
end
but it gives me this error:
Reference to non-existent field 'Field1'.
Can someone please point out whats wrong here?
Thanx