How do I write a for loop that stacks the columns of a matrix vertically into a single column array?
3 ビュー (過去 30 日間)
古いコメントを表示
I have a 3x4 matrix and I need to stack the columns in order into a vertical stack.
0 件のコメント
回答 (1 件)
ag
2024 年 12 月 4 日
Hi Elias,
To reshape the matrix into a column vector, you can use the colon operator.
The below code demonstrates the same:
A = [1 2 3 4;
5 6 7 8;
9 10 11 12]
stackedMatrix = A(:)
For more details, please refer to the following MathWorks documentation: colon - https://www.mathworks.com/help/matlab/ref/double.colon.html?searchHighlight=%3A&s_tid=srchtitle_support_results_1_%253A#:~:text=Reshape%20the%20matrix%20into%20a%20column%20vector.
Hope this helps!
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!