plot 2 3D vectors in Matlab

26 Ansichten (letzte 30 Tage)
ektor
ektor am 21 Feb. 2020
Beantwortet: Fabio Freschi am 21 Feb. 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?

Antworten (1)

Fabio Freschi
Fabio Freschi am 21 Feb. 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])

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by