how can i give a third vector i don't have the same length of the first two?

1 visualización (últimos 30 días)
in this problem i have 3 points M1 (12, 45, -5) M2 (24, -3, -5) M3 ( 4, 15, -5) and i have to plot two vectors, V1 going from M1 to M2 and V2 going from M1 to M3, but I don't know what to do for the third vector the error message says i have to input when i try to use plot3.
What can i do to solve this?

Respuestas (2)

Ameer Hamza
Ameer Hamza el 12 de Oct. de 2020
Editada: Ameer Hamza el 12 de Oct. de 2020
Are you trying to plot three lines?
M1 = [12, 45, -5];
M2 = [24, -3, -5];
M3 = [4, 15, -5];
axes();
hold on
grid on
view(3)
% plot V1: M1->M2
plot3([M1(1) M2(1)], [M1(2) M2(2)], [M1(3) M2(3)])
% plot V2: M1->M3
plot3([M1(1) M3(1)], [M1(2) M3(2)], [M1(3) M3(3)])
% plot V3: M2->M3
plot3([M2(1) M3(1)], [M2(2) M3(2)], [M2(3) M3(3)])

KSSV
KSSV el 12 de Oct. de 2020
M1 = [12, 45, -5] ;
M2 = [24, -3, -5] ;
M3 = [ 4, 15, -5] ;
hold on
plot3([M1(1) M2(1)],[M1(2) M2(2)],[M1(3) M2(3)],'b')
plot3([M1(1) M3(1)],[M1(2) M3(2)],[M1(3) M3(3)],'r')
  4 comentarios
KSSV
KSSV el 12 de Oct. de 2020
You can try like this too:
M1 = [12, 45, -5] ;
M2 = [24, -3, -5] ;
M3 = [ 4, 15, -5] ;
hold on
v1 = M2-M1 ;
v2 = M3-M1 ;
v3 = M3-M2 ;
quiver3(M1(1),M1(2),M1(3),v1(1),v1(2),v1(3),'r')
quiver3(M1(1),M1(2),M1(3),v2(1),v2(2),v2(3),'b')
quiver3(M2(1),M2(2),M2(3),v3(1),v3(2),v3(3),'g')
Niccolò Moretto
Niccolò Moretto el 12 de Oct. de 2020
oh sorry yeah i got confused, Thanks to all of you for the help!

Iniciar sesión para comentar.

Categorías

Más información sobre Lighting, Transparency, and Shading 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