Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[MATLAB] Subscripted assignment dimension mismatch.

  1. Nov 2, 2011 #1
    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'.
    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
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted