Best Way to Convert Data in a Structure to an Array
1 回表示 (過去 30 日間)
古いコメントを表示
I am doing the following to convert data in a structure to an array. It seems a little clunky. Is there a better way?
a(1).data = [1 2];
a(2).data = [3 4];
a(3).data = [5 6];
a(4).data = [7 8];
data2 = cell2mat({a.data}');
2 件のコメント
Bob Thompson
2021 年 2 月 26 日
data2 = vertcat(a(:).data);
I don't have a good way to make your definition of a.data any better.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!