atan2 & mod number not converges to correct value???
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi All,
I am calculating principle axis values using eigen values and calculating the angles ang1 & ang2 as below.
clear all; clc;
Ix0 = 1.3562e+08;
Iy0 = 3.3113e+06;
Ixy0 = 2.9802e-07;
I = [ Ix0 -Ixy0 ;
-Ixy0 Iy0 ];
[ eig_vec, eig_val ] = eig(I);
I1 = eig_val(1,1);
I2 = eig_val(2,2);
ang1 = atan2( eig_vec(2,1), eig_vec(1,1) );
ang2 = atan2( eig_vec(2,2), eig_vec(1,2) );
ang1_d = ang1*180/pi;
ang2_d = ang2*180/pi;
ang1_ = mod(abs(ang1_d), 90);
ang2_ = mod(abs(ang2_d), 90)
ang2_ =
90.0000
ang2_ = mod(abs(ang2_d), 90) shoud be ~= 0, but it is not. What's wrong in here?
0 comentarios
Respuestas (1)
Steven Lord
el 8 de Jul. de 2019
First, if you want angles in degrees use atan2d directly.
But as for what you're seeing with ang2_ being 90.0000? Your angle is not exactly ninety but is very slightly less than ninety, small enough that mod(..., 90) returns the number itself but close enough that to four decimal places it is 90.0000. See how far away it is from ninety.
difference = 90-ang2_
The value of difference will not be 0, but it will be a very small number.
Ver también
Categorías
Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!