- #1
hoheiho
- 47
- 0
Halo everyone, I am trying to consider a dice game using MATLAB. I used 'r=randi(6,a,b)' to get random number from MATLAB.Also run it for 200times.(a=a:1:x,b=b:1:y) Then used '[a,b]=mode(r)' to get the highest frequency value and add them together then put them in the table. For x=1 with y=1,2 or 3 is fine for my program coz its just 1x3 matrix. And now i want to get the x=2 with y=1,2 or 3 then the matrix will be 2x1,2x2 or 2x3. But what i want is just the red colour part in the table. Becuase if i used 2x1 matrix it will cause error for my 'sum' command so the arrey will not be balance and it case 'Subscripted assignment dimension mismatch'.
y
x 1 2 3
1 4.0 4.0 3.5
2 5.0 5.0 4.0
3 3.0 3.0 3.0
I have google it and it say i can use 'repmat' to build up a large matrix first, calculate the value 1 by 1 and then put it in the large matrix. But I am not quite understand how to use it. Is there anyone can give me a hand for this?
Thank you very much
y
x 1 2 3
1 4.0 4.0 3.5
2 5.0 5.0 4.0
3 3.0 3.0 3.0
I have google it and it say i can use 'repmat' to build up a large matrix first, calculate the value 1 by 1 and then put it in the large matrix. But I am not quite understand how to use it. Is there anyone can give me a hand for this?
Thank you very much