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/plotvector3.m
2014-11-12 18:39:02 +01:00

25 lines
625 B
Matlab

function plotvector3( v, s, sp )
% plot an arrow for the 3D-vector v
% v: the 3D 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
quiver3( [0.0], [0.0], [0.0], [v(1)], [v(2)], [v(3)], 1.0, s );
view( 42, 12 );
grid on
if nargin == 3
hh = ishold;
if ~hh
hold on;
end
plot3( [v(1) v(1)], [v(2) v(2)], [0.0 v(3)], sp );
plot3( [0.0 v(1) v(1)], [v(2) v(2) 0.0], [0.0 0.0 0.0], sp );
if ~hh
hold off;
end
end
end