How to assign values to a variable size array
2 ビュー (過去 30 日間)
古いコメントを表示
The following works fine
k=[];
for jj=1:10
k(jj,:)=randi(10,1,3);
end
However, I'm facing difficulties when I try to assign different rows' elements to variable size array k:
k=[];
for jj=1:10
k(1,:)=randi(10,1,jj);
end
I would appreciate your help.
6 件のコメント
Walter Roberson
2021 年 2 月 21 日
N = 10;
k = cell(N,1);
for jj = 1:N
k{jj} = randi(10,1,jj);
end
k
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!