How to concatenate matrices using for loop?
3 ビュー (過去 30 日間)
古いコメントを表示
Abdulaziz Abutunis
2017 年 12 月 8 日
コメント済み: Abdulaziz Abutunis
2017 年 12 月 9 日
Dear All:
I have a group of matrices of size (100X3). If possible, I want to concatenate them in one larger matrix using a for a loop. I want to use a loop because the number of matrices differs for each run so using the command [ x1 x2 ...] is not practical.
Thank you, Aziz
2 件のコメント
James Tursa
2017 年 12 月 9 日
How are the individual matrices stored? In individual variable names like x1, x2, etc.? Or in a cell array? Or as fields of a struct? Or ...?
採用された回答
James Tursa
2017 年 12 月 9 日
If x is a cell array, and you simply want all of them, then
result = cell2mat(x);
or if you want them stacked vertically
result = cell2mat(x');
If you want a subset of the cells, then specify the range. E.g.,
result = cell2mat(x(range));
or if you want them stacked vertically
result = cell2mat(x(range)');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!