plot 2 3D vectors in Matlab

33 visualizaciones (últimos 30 días)
ektor
ektor el 21 de Feb. de 2020
Respondida: Fabio Freschi el 21 de Feb. de 2020
Dear all,
I have these vectors
a = [1 2 -3];
b = [-3 12 -13];
Both start from c=[0 0 0];
How can I plot them in a 3D envirorment?
Can you provide with a sample code?

Respuestas (1)

Fabio Freschi
Fabio Freschi el 21 de Feb. de 2020
% vectors
a = [1 2 -3];
b = [-3 12 -13];
% starting point
C0 = [0 0 0];
% put vector in a matrix, to make the code more flexible (e.g. more vectors)
V = [a; b];
% replicate the starting point for all vectors
C = repmat(C0,size(V,1),1);
% plot
figure, hold on
quiver3(C(:,1),C(:,2),C(:,3),V(:,1),V(:,2),V(:,3))
% change point of view
view([1 1 1])

Categorías

Más información sobre Line Plots 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