フィルターのクリア

how to format vector as matrix?

1 回表示 (過去 30 日間)
Berbia
Berbia 2012 年 12 月 1 日
I have a long row vector say,v=[1 2 3 ... 100]. I'm in need to convert it into a matrix m=[1 2 3 4 5;6 7 8 9 10; ..... ;96 97 98 99 100] i.e),for each row 5 elements...Is it possible in matlab? if so how???

採用された回答

Walter Roberson
Walter Roberson 2012 年 12 月 1 日
m = reshape(v, 5, []) .' ;
Notice this first creates columns of 5 and then transposes so they become rows, rather than creating rows of 5 directly. This has to do with the order that reshape() takes elements to be reshaped.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by