MATLAB: Perform command on whole structure (reduce size)

structures

Hello I have a data structure (named 'Data'). It is a mix of two and three tiers. It consists of a load of data arrays in roughly the same dimensions (9111 x 9021 or 9111 x 9020). I want to crop all of the arrays in one go i.e. I want a new structure which is the same but has (400:7000,4000:8000) of each array.
Is there a way to do this, instead of doing B1_2 = Data.sat.B1(400:7000,4000:8000); for every array?
Apologies if answered before, I couldn't find any results, perhaps b/c I'm not sure on the terminology. Thank you

Best Answer

If it is a struct, use structfun with 'uniform', 0 . You will probably find it easier to write a small recursive routine:
function r = trimstruct(s)
if isstruct(s)
r = structfun(@trimstruct, s, 'Uniform', 0);
else
r = s(400:7000,4000:8000);
end
end