Select a random element of a vector and use randi command
古いコメントを表示
What command should I use to randomly select an element from a vector and give it a random number by using the randi command while also displaying the other elements in the workspace?
回答 (1 件)
KSSV
2021 年 3 月 1 日
A = magic(5) ;
A = A(:) ;
N = numel(A) ;
idx = randi(N,1) ;
A(idx) = rand
1 件のコメント
Eric Junaeus
2021 年 3 月 2 日
編集済み: Eric Junaeus
2021 年 3 月 2 日
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!