필터 지우기
필터 지우기

Random numbers

조회 수: 1 (최근 30일)
Sujan
Sujan 2012년 4월 18일
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 ?

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 4월 18일
idx = [1,2,4,7,8];
out = zeros(10,1);
out(idx)=rand(numel(idx),1);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by