Perform command on whole structure (reduce size)

조회 수: 6 (최근 30일)
Grant
Grant 2015년 5월 13일
댓글: Grant 2015년 5월 13일
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

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 13일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by