Scale Matrix Dimensions by Factor

I have a matrix that needs to be scaled in the horizontal, copying each row.
Ex:
[1 2 3]
[4 5 6]
Scale Columns only by Factor 3
[1 1 1 2 2 2 3 3 3]
[4 4 4 5 5 5 6 6 6]
How can I write a simple loop to perform this. Thanks!

 採用された回答

Bruno Luong
Bruno Luong 2018 年 11 月 16 日

0 投票

>> repelem([1 2 3],3)
ans =
1 1 1 2 2 2 3 3 3
>>

4 件のコメント

Philip
Philip 2018 年 11 月 16 日
I think that repeats in columns and rows though? I need to repeat columns, keep same number of rows.
Bruno Luong
Bruno Luong 2018 年 11 月 16 日
1 x 3 matrix in 1 x 9 matrix out, repeats rows you said?
Bruno Luong
Bruno Luong 2018 年 11 月 16 日
I think I understand now your incorrect MATLAB notation
>> repelem([1 2 3; 4 5 6],1,3)
ans =
1 1 1 2 2 2 3 3 3
4 4 4 5 5 5 6 6 6
>>
Philip
Philip 2018 年 11 月 16 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018a

質問済み:

2018 年 11 月 16 日

コメント済み:

2018 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by