how would I randomly replace two elements in a row vector
이전 댓글 표시
rn, i have:
y = char(randperm(27));
for i = 1:iter
ynew = randperm(numel(y), 2);
댓글 수: 1
Rena Berman
2024년 3월 15일
(Answers Dev) Restored edit
답변 (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
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!