what the fault in my code

1 visualización (últimos 30 días)
Mohammed Alabiech
Mohammed Alabiech el 27 de Ag. de 2017
Editada: Jan el 28 de Ag. de 2017
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

Respuesta aceptada

John D'Errico
John D'Errico el 28 de Ag. de 2017
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.
  1 comentario
Jan
Jan el 28 de Ag. de 2017
Editada: Jan el 28 de Ag. de 2017
+1. Example to reproduce this behavior:
a = uint8(16);
a(1) = 1966;
disp(a)
>> 255

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by