How can I plot two vectors starting from origin?
14 次查看(过去 30 天)
显示 更早的评论
I wrote the following code to set the appearance of the axis and the figure:
search_width = 5;
figure2 = figure;
% Figure erstellen
axes2 = axes('Parent',figure2);
hold(axes2,'on');
% Axen erstellen
figure2.Name = sprintf('Vektoren in der Suchmaske - alpha = %g', alpha(1, 1));
figure2.NumberTitle = 'off';
% Titel des Fensters bearbeiten
axes2.XLim = [ (-(round((search_width/2)+1))) (round((search_width/2)+1))];
axes2.YLim = [ (-(round((search_width/2)+1))) (round((search_width/2)+1))];
axes2.XAxisLocation = 'origin';
axes2.YAxisLocation = 'origin';
% Achsen in den Mittelpunkt verschieben
% Vektoren
box(axes2,'on');
% Einstellungen zum Aussehen des Schaubildes
Now I want to plot two vectors.
a = [-3; -3]
b = [-3; 0]
a and b determines the end of the vectors. Starting-point shall be for both vectors the point [0, 0]. It would be nice if the vectors have the appearance of arrows. How can I manage this?
I use MATLAB R2015b.
0 个评论
采纳的回答
Star Strider
2015-10-21
Use the quiver function:
o = [0; 0];
a = [-3; -3];
ac = [a o];
auv = [o a];
b = [-3; 0];
bc = [b o];
buv = [o b];
figure(1)
quiver(ac(1,:), ac(2,:), auv(1,:), auv(2,:), 0)
hold on
quiver(bc(1,:), bc(2,:), buv(1,:), buv(2,:), 0)
hold off
axis([-5 1 -5 1])
更多回答(1 个)
TastyPastry
2015-10-21
编辑:TastyPastry
2015-10-21
There is a method using annotation() and another using quiver(). They quiver() method doesn't draw exact vectors to the endpoint.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!