How to mix integers and chars in matrix?
이전 댓글 표시
1. I want to create the following matrix:
A=[1 2 3 A B C]
2. After that, based on the matrix A, I want to generate random matrix of this following matrix:
A1=[1 3 2 A C B]
A2=[2 1 3 B A C]
A2=[2 3 1 B C A]
Does any body can help me?
댓글 수: 1
Paulo Silva
2011년 1월 27일
Not possible inside matrix, you must use cells
채택된 답변
추가 답변 (3개)
Sebastian
2011년 1월 27일
Well, you could do something like
>> a = '123ABC';
>> l = size(a,2);
>> rp = randperm(l/2);
>> a1 = a([rp rp+l/2])
a1 =
321CBA
zakri
2011년 1월 28일
댓글 수: 9
Paulo Silva
2011년 1월 28일
char(AA)
zakri
2011년 1월 28일
Paulo Silva
2011년 1월 28일
find what's wrong with your code, that's the better way to learn.
Paulo Silva
2011년 1월 28일
hint: You got all the code in there but one line of it is in the wrong place :)
zakri
2011년 1월 29일
Paulo Silva
2011년 1월 29일
You are only shuffling the cards once, that's why you get always the same result, shuffle the cards 3 times...
zakri
2011년 1월 31일
Paulo Silva
2011년 1월 31일
already did lol
c'mon you just need to put the randperm inside the loop, so easy :)
zakri
2011년 1월 31일
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!