Error: Unable to perform assignment because the left and right sides have a different number of elements.
3 ビュー (過去 30 日間)
古いコメントを表示
I am unable to get this for loop working for some reason, I know it is in line 28 but not sure. Thanks for any help.
0 件のコメント
採用された回答
fred ssemwogerere
2020 年 2 月 13 日
編集済み: fred ssemwogerere
2020 年 2 月 13 日
You are using a double for loop. I advise its best to use something like this
for ii=1:24
for jj=1:24
z(ii,jj)=normrnd(mu_SC(ii),std_SC(jj),1000);
end
end
3 件のコメント
fred ssemwogerere
2020 年 2 月 13 日
Hello, from your question i think you are tring to generate a 1000x1000 array of normal random numbers, then in that case you can use cell notation, with curly brackets to the output as below:
for ii=1:24
for jj=1:24
z{ii,jj}=normrnd(mu_SC(ii),std_SC(jj),1000);
end
end
Stephen23
2020 年 2 月 13 日
With preallocation to avoid inefficiency and some errors related to unmatching classes/types/sizes:
z = cell(24,24);
for ...
end
その他の回答 (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!