MATLAB: What the fault in the code

array problem

I have problem with this code
skAx=1966
skAy=4372
p=5449
Pmlx(1)=10
Pmly(1)=2
Cm3(1)=mod(Pmlx(1)+skAx+skAy,p)
Cm4(1)=mod(Pmly(1)+Cm3(j),p)
when I implement, the result below
Cm3 = 255
Cm4 = 255
while the correct result must be
Cm3 = 899
Cm4 = 901

Best Answer

  • Hint: Don't stuff your results into vectors that are defined to be uint8.
    The test is simple.
    class(Pmlx)
    class(Pmly)
    class(cm3)
    class(cm4)
    One or more of those variables is uint8.