Could anyone help me how to generate the matrix in the following manner as described below
1 回表示 (過去 30 日間)
古いコメントを表示
I want to generate a matrix of size
(1500x1)
in which first 100 rows should be having the value of 1, next 200 rows should be having the value of 1 and 2 arranged randomly, next 300 should be having the value of 1,2 and 3 arranged randomly, next 400 rows should be having the value of 1,2,3 and 4 arranged randomly and next 500 rows should be having the value of 1,2,3, 4 and 5 arranged randomly.
Could anyone please help me on this.
0 件のコメント
採用された回答
Bruno Luong
2021 年 8 月 4 日
編集済み: Bruno Luong
2021 年 8 月 4 日
hi=repelem((1:5)',100*(1:5));
r=ceil(rand(size(hi)).*hi)
0 件のコメント
その他の回答 (2 件)
Vignesh Murugavel
2021 年 8 月 4 日
This should do it.
m1 = ones([100,1]);
m2 = randi([1 2],200,1);
m3 = randi([1 3],300,1);
m4 = randi([1 4],400,1);
m5 = randi([1 5],500,1);
Ans = [m1 ; m2;m3;m4;m5];
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!