split struct based on description
4 ビュー (過去 30 日間)
古いコメントを表示
Hi. How do you subdivide the struct into multiple structs as shown in the figure?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1411039/image.png)
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!