How to delete/copy (store) rows of a struct?

조회 수: 15(최근 30일)
Peter Meier
Peter Meier 2020년 7월 27일
답변: Stijn Haenen 2020년 7월 27일
One simply question: How can i delete rows of a struct? For example 1*45 struct the last 13 rows? Or how can i copy/store somewhere else the last 13 rows?
Thank you so much.

채택된 답변

Arthur Roué
Arthur Roué 2020년 7월 27일
You can do as a regular array :
myStruct; % 1x45 strcu-array
% Split index
k = numel(myStruct) - 13;
% Slice structure
myStruct(1:k) % first elements before k
myStruct((k+1):end); % last element, from k to end

추가 답변(1개)

Stijn Haenen
Stijn Haenen 2020년 7월 27일
You can delete the last 13 rows with:[1:45]';[];


Community Treasure Hunt

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

Start Hunting!

Translated by