How to delete/copy (store) rows of a struct?
19 次查看(过去 30 天)
显示 更早的评论
Hello,
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.
0 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
Stijn Haenen
2020-7-27
You can delete the last 13 rows with:
struc.data=[1:45]';
struc.data(end-12:end)=[];
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!