Cross Product is Returning Values way to small to be right
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pete
el 29 de Ag. de 2018
Comentada: Steven Lord
el 29 de Ag. de 2018
Hi,
I am trying to determine the cross product of two vectors while having MATLAB calculate the components and then cross them. Every time it runs it spits out an answer like 1.0e-15. Does anyone know what is causing this? I'm new to MATLAB and all help is appreciated.
clear all;
close all;
A=2.8;
B=1.9;
Ax=A*cos(60*(180/pi)); %Finds the x component to vector A
Ay=A*sin(60*(180/pi));
Az=0;
Bx=B*cos(60*(180/pi)); %Finds the x component to vector A
By=B*sin(60*(180/pi));
Bz=0;
A=[Ax Ay Az];
B=[Bx By Bz];
C=cross(A,B);
disp (C);
0 comentarios
Respuesta aceptada
James Tursa
el 29 de Ag. de 2018
Your vectors are parallel to each other, so the answer should be 0. The small number you are getting is just from floating point calculation effects.
Also, your apparent conversion from degrees to radians is backwards. You need the factor to be (pi/180) instead of the (180/pi) you are currently using.
1 comentario
Steven Lord
el 29 de Ag. de 2018
Rather than converting from degrees to radians, use the degree-based trig functions sind and cosd instead of the radian-based sin and cos.
Más respuestas (0)
Ver también
Categorías
Más información sobre Arithmetic Operations 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!