Why does MODE function return erroneous results in my script in MATLAB 8.0 (R2012b)?
Mostrar comentarios más antiguos
Consider the following:
pts = [-0.6 -6;-0.2 0;0 3;-0.8 -9;-2 1;-0.4 -3];
m=(pts(2:end,2)-ones(length(pts(:,1))-1,1)*pts(1,2)) ./ (pts(2:end,1)-ones(length(pts(:,1))-1,1)*pts(1,1))
The output is:
m =
15.0000
15.0000
15.0000
-5.0000
15.0000
However, when I type 'mode(m)' I get a clearly incorrect answer:
mode(m)
ans =
-5
And, when I do the following, I get the correct answer:
zz=str2num(num2str(m));
mode(zz)
ans =
15
Can you explain what is going on here?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!