Random numbers
1 回表示 (過去 30 日間)
古いコメントを表示
I have a problem regarding random numbers. Suppose I have a zero vector with length 10. I want to generate random numbers only on position 1,2,4,7,8. How do I generate random numbers only on these positions ? Is there any command ?
0 件のコメント
採用された回答
Andrei Bobrov
2012 年 4 月 18 日
idx = [1,2,4,7,8];
out = zeros(10,1);
out(idx)=rand(numel(idx),1);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!