Deleting last element of a nested structure

조회 수: 9 (최근 30일)
Deepayan Bhadra
Deepayan Bhadra 2020년 11월 11일
편집: Stephen23 2020년 11월 11일
MySignalData here has multiple 1x1 structs like DIA,DIB,...DIZ,timestamp. Each DIA etc. has multiple 1x1 structs like pt1151,pt9999 etc which has a Data variable. I want to remove the last element in Data such that the size is 21707x1 and I want to apply this to all such ptxxxx in DIA,...DIZ.
How do I vectorize this process or I need to do in a for-loop? Even with a loop, it seems a daunting exercise. Any input is welcome.
  댓글 수: 1
Stephen23
Stephen23 2020년 11월 11일
편집: Stephen23 2020년 11월 11일
"How do I vectorize this process or I need to do in a for-loop?"
Most likely you will need two loops and to use both of these:
It would be simpler with non-scalar structures, rather than putting meta-data into fieldnames.

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

답변 (1개)

Sudhakar Shinde
Sudhakar Shinde 2020년 11월 11일
To remove filed from structure check rmfield.
Example:
s.a = 1;
s.b = 2;
s.c = 3;
Remove field b.
field = 'b';
s = rmfield(s,field)
s = struct with fields:
a: 1
c: 3

카테고리

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

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by