% MATLAB script: demonstration plot() functions

% Plots in 2D
figure; 
% Plot a point in 2D, marker is a red plus sign
x = 0.5; y = 0.7; plot(x,y,'r+');
axis([-1 1 -1 1]); % Set axis
hold on; % Use the same coordinate system for following plot commands
% Plot a number of points 
vx = [1;2;3;4;5]/10; wy = vx.^2; plot(vx,wy,'m*'); 
% Plot a blue closed polygon
N = 10; 
x = []; y = []; z = []; % Initialize \emph{empty} vectors
for i=1:N
  x = [x;cos((i-1)/N*2*pi)]; y = [y;sin((i-1)/N*2*pi)]; z = [z;i/N]; 
end
X = 0.5*[x;x(1)]; Y = 0.5*[y;y(1)]; % Ensure that polygon is closed
plot(X,Y,'b-'); 

pause; % Wait for a key being pressed

% Plot vector arrows
quiver(vx(1:end-1),wy(1:end-1),...
       vx(2:end)-vx(1:end-1),wy(2:end)-wy(1:end-1),'r');

pause; % Wait for a key being pressed

% Plots in 3D: a red spiral
figure; plot3(x,y,z,'r-*');
