How do I create a (10,10) matrix containing numbers from 1 to 100?
462 ビュー (過去 30 日間)
古いコメントを表示
How do I create a (10,10) matrix containing numbers from 1 to 100?
I just want the numbers to go 1 to 10 on the top row, then 11-20 on the 2nd row etc.
2 件のコメント
採用された回答
その他の回答 (4 件)
Steven Lord
2022 年 1 月 25 日
Another solution using implicit expansion (which wasn't available back in 2013 when this question was posted):
n = 10;
A = (1:n) + n*(0:n-1).'
0 件のコメント
SYED ABOU ILTAF HUSSAIN
2018 年 9 月 2 日
編集済み: SYED ABOU ILTAF HUSSAIN
2018 年 9 月 2 日
Try this a= [1:10]; for i=2:10 a(i,:)=a(i-1,:)+10; end
0 件のコメント
finess
2022 年 8 月 26 日
8 件のコメント
Walter Roberson
2022 年 8 月 27 日
編集済み: Walter Roberson
2022 年 8 月 27 日
There are a number of different ways to achieve the same result.
A = 100 + zeros(4,4)
A = 100 * ones(4,4)
A = 100; A = A(ones(4,4))
A = zeros(4,4); A(:) = 100
A(1:4,1:4) = 100
A = repmat(100,4,4)
finess
2022 年 8 月 28 日
Wow I love these Answers! It gives me a feeling of how a great teacher looks like, with great options for students
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!