plot 2 3D vectors in Matlab

12 ビュー (過去 30 日間)
ektor
ektor 2020 年 2 月 21 日
回答済み: Fabio Freschi 2020 年 2 月 21 日
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?

回答 (1 件)

Fabio Freschi
Fabio Freschi 2020 年 2 月 21 日
% 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])

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by