What is the problem? :) You did it correctly. Well, except for the very last line.
n = 19
d = 3
r = rem(n,d)
q = (n-r)/d
As you should know, 19 can be written as 6*3 + 1. So we found r=1, and q = 6. Perfect. WTP?
Error using disp
Too many input arguments.
Your problem was in the use of disp. You might do it like this instead:
Oh, you will also find that using a semi-colon at the end of your lines is a good idea as you go further. Otherwise, MATLAB will dump reams and reams of junk on the commandline.
Finally, be careful using rem, since rem and mod have subtly different behaviors for negative arguments. So I would note that:
returns a remainder that does not live in the interval [0,d-1].