Randperm without number 1

조회 수: 2 (최근 30일)
Mary Hemler
Mary Hemler 2020년 5월 14일
편집: Stephen23 2020년 5월 14일
I am using randperm to select positions that will be changed. How can I change my code so that the number 1 (position 1) is not included?
N = 50;
N20 = .2*N;
r = randperm(N,N20); %positions that are about to be changed
for y=r
S20a(:,y)=2*round(rand(1)) - 1;
end

채택된 답변

Stephen23
Stephen23 2020년 5월 14일
편집: Stephen23 2020년 5월 14일
r = 1+randperm(N-1,N20);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by