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!