I am looking for something similar to sapply function in R in Matlab. I have the current issue:
I have a large struct of size 1000, each one inside is a struct, that is, I have a struct of struct.
Each substruct are in the same style, that is, the same fields.
I am using a function to do something on each substruct
The code looks like:
for i =1:length(mainStruct)
disp(i);
result(i) = myfunction(mainStruct(i).field(1:1000));
end
In the above, myfunction is just a function, mainStruct is the sturct of struct, mainStruct(i) is accessing each subStruct.
I have tried structfun, but it only works on struct's field names, not on struct of struct.
The question is how I can get rid of this loop?