Professional Documents
Culture Documents
Vector
Vector
function kelili(p0,p1,label)
%WELCOME to my project
%this function of script for draw the vector arrow in 2D & 3D,
this skrip is free copyright, but please include the source from
which you obtain it.
%Created By: ADE JUNAIDI STC (1300022010)
% Example:
% 3D vector
% p0 = [1 2 3]; % Coordinate of the first point p0
% p1 = [4 5 6]; % Coordinate of the second point p1
% vector(p0,p1,'label')
%
% 2D vector
% p0 = [1 2]; % Coordinate of the first point p0
% p1 = [4 5]; % Coordinate of the second point p1
% vector(p0,p1,'label')
if max(size('p0'))==3
if max(size(p1))==3
x1 = p0(1);
y1 = p0(2);
z1 = p0(3);% Coordinate of the first point p0
x2 = p1(1);
y2 = p1(2);
z2 = p1(3);% Coordinate of the second point p1
grid on
xlabel('x')
ylabel('y')
zlabel('z')
hold on
else
error('p0 and p1 must have the same dimension.......
Please Clear and Try again')
end
elseif max(size(p0))==2
if max(size(p1))==2
x1 = p0(1);
y1 = p0(2); % coordinate of the first point
x2 = p1(1);
y2 = p1(2);% coordinate of the second point
xl=(p1(1)+p0(1))/2;
yl=(p1(2)+p0(2))/2;