Extract partial data from vectors in structure
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(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!