필터 지우기
필터 지우기

how would I randomly replace two elements in a row vector

조회 수: 1 (최근 30일)
Samuel
Samuel 2024년 2월 13일
편집: Rena Berman 2024년 3월 15일
rn, i have:
y = char(randperm(27));
for i = 1:iter
ynew = randperm(numel(y), 2);

답변 (1개)

Walter Roberson
Walter Roberson 2024년 2월 13일
편집: Walter Roberson 2024년 2월 13일
y = char(randperm(27) - 1 + 'A');
for i = 1:iter
idx = randperm(numel(y), 2);
ynew = y;
ynew(idx) = ynew([idx(2) idx(1)]);
end

카테고리

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