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 Center および File ExchangeNumerical 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