plot 2 3D vectors in Matlab
16 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Fabio Freschi
on 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])
0 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!