array to matrix
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have an array like a:
a=[10 20 30 40];
I want to convert it to the matrix below, without using any for loop just by one command.
b=[ 10 10 20 20 30 30 40 40
10 10 20 20 30 30 40 40
10 10 20 20 30 30 40 40];
How can I do it. Thank you,
0 件のコメント
採用された回答
その他の回答 (1 件)
Titus Edelhofer
2012 年 4 月 23 日
Hi Som,
the function you are looking for is named
repmat
Titus
2 件のコメント
Titus Edelhofer
2012 年 4 月 23 日
Hi Andrei, thanks! I admit I did not see the repetitions in the rows, so my solution would be repmat + reshape. Using kron is in this case the more elegant solution.
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!