필터 지우기
필터 지우기

Extract partial data from vectors in structure

조회 수: 1 (최근 30일)
yonatan s
yonatan s 2019년 11월 28일
댓글: Stephen23 2019년 11월 28일
I have a structure containing multiple fields of size 1XN and 3XN. I'm looking for a simple way to extract partial data, e.g. the new structure will contain the same fields as the original, but of sizes 1XN-x and 3XN-x.
Thanks.

채택된 답변

Stephen23
Stephen23 2019년 11월 28일
>> S.A = 0:3;
>> S.B = 4:9
S =
scalar structure containing the fields:
A =
0 1 2 3
B =
4 5 6 7 8 9
>> x = 2;
>> Z = structfun(@(v)v(:,1:end-x),S,'UniformOutput',false)
Z =
scalar structure containing the fields:
A =
0 1
B =
4 5 6 7
  댓글 수: 2
yonatan s
yonatan s 2019년 11월 28일
Thanks. Is it possible to do the same using a logical array, instead of 1:end-x?
Stephen23
Stephen23 2019년 11월 28일
"Is it possible to do the same using a logical array, instead of 1:end-x?"
Yes.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by