MATLAB [MATLAB] Subscripted assignment dimension mismatch.

  • Thread starter hoheiho
  • Start date
Halo everyone, im 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 wanna 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 im not quite understand how to use it. Is there anyone can give me a hand for this?
Thank you very much
 

Want to reply to this thread?

"[MATLAB] Subscripted assignment dimension mismatch." You must log in or register to reply here.

Related Threads for: [MATLAB] Subscripted assignment dimension mismatch.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top