Sequential, row-wise reshape of an M–by–N matrix to form a 1–by–N vector

7 ビュー (過去 30 日間)
Raymond MacNeil
Raymond MacNeil 2020 年 4 月 22 日
コメント済み: Raymond MacNeil 2020 年 4 月 22 日
Dumb question. Let's say I have the following matrix:
A = [2 1
4 3
6 5
8 7
10 9];
Is there a way to use circshift(), some combinaton of circshift(), reshape(), transpose(), etc, or other set of functions to obtain the following.
A = somefun(A) % or combinaton of functions and operations
A =
2 1 4 3 6 5 8 7 10 9
I could easily obtain this result with with a for loop, but I am wondering if there is another means to go about this. Notice that the rows are sequentially 'stacked' along the N–dimension. The question could similarly be phrased in terms of columns to produce an M–by–1 column vector.
Edit: Accidental, premature submit.

採用された回答

Stephen23
Stephen23 2020 年 4 月 22 日
reshape(A.',1,[])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by