23 lines
513 B
Matlab
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
|