This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/linearalgebra/code/plotvector.m
2014-11-12 18:39:02 +01:00

23 lines
513 B
Matlab

function plotvector( v, s, sp )
% plot an arrow for the 2D-vector v
% v: the 2D vector
% s: a string passed to quiver for the color
% sp: if this string is set it defines the color of some helper lines
if nargin < 2
s = 'b';
end
quiver( [0.0], [0.0], [v(1)], [v(2)], 1.0, s );
grid on;
if nargin == 3
hh = ishold;
if ~hh
hold on;
end
plot( [0.0 v(1) v(1)], [0.0 0.0 v(2)], sp );
if ~hh
hold off;
end
end
end