split struct based on description
7 次查看(过去 30 天)
显示 更早的评论
Hi. How do you subdivide the struct into multiple structs as shown in the figure?
0 个评论
采纳的回答
Stephen23
2023-6-15
C = {S.SeriesDescription};
S_scout = S(strcmpi(C,'Scout'))
S_serie = S(strcmpi(C,'Serie'))
S_stand = S(strcmpi(C,'Standard'))
If you want to do it "automatically" for multiple different strings:
Note that splitting up data is rarely a good approach to processing data. Usually keeping data together makes it easier to process.
2 个评论
Stephen23
2023-6-15
编辑:Stephen23
2023-6-15
"How can I do it if I want to directly use the names in the cell and create the substructures simultaneously?"
If you really want to force yourself into writing slow, complex, inefficient, obfuscated, buggy code that is harder to debug, you can find plenty of examples linked here:
更多回答(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!