Pseudorandom character matrix generation
조회 수: 2 (최근 30일)
이전 댓글 표시
Generate a 10x10 matrix with the letters 'b', 'd', 'p', 'q' in randomized order. Every refresh should produce a new randomized matrix.
This is to simulate the bdpq test. Should be a pretty simple task, but seems to be otherwise!
댓글 수: 0
채택된 답변
Rik
2022년 9월 29일
If you want a 10x10 char array, you can also use indexing:
source = 'bdpq';
Array = source(randi(end,[10 10]))
댓글 수: 3
Rik
2022년 9월 30일
I can't say I understand what you want to do, so I don't have any suggestions. Your steps don't seem very complicated, so I don't expect to have a much better solution.
추가 답변 (1개)
KSSV
2022년 9월 29일
s = {'b', 'd', 'p', 'q' } ;
S = cell(10) ;
for i = 1:10
for j = 1:10
t = s(randperm(4,4)) ;
S{i,j} = [t{:}] ;
end
end
S
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!