필터 지우기
필터 지우기

Copy range of values from all fields in a structure to another structure

조회 수: 2 (최근 30일)
kevin
kevin 2015년 12월 14일
댓글: kevin 2015년 12월 14일
Lets say I have the following struct: data = FIELD1: [1x250 double] FIELD2: [1x250 double]
I want to copy the range (25:50) from both fields into a new struct where the result would look like new = FIELD1: [1x26 double] FIELD2: [1x26 double] I know I can do this in a loop using fieldnames but would like to find a more direct approach.

채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 14일
newStruct = structfun(@(V) V(25:50), oldStruct, 'Uniform', 0);
No explicit loop needed.

추가 답변 (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