how would I randomly replace two elements in a row vector
조회 수: 1 (최근 30일)
이전 댓글 표시
rn, i have:
y = char(randperm(27));
for i = 1:iter
ynew = randperm(numel(y), 2);
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!