%
% Basic 1D plotting example
%

clear all;
clf;

% define start/end points for the x-axis
xmin = 1.0;
xmax = 10.0;

% number of sample points
npoints = 23;

% create array of length npoints with values [xmin, ... xmax]
xdata = linspace(xmin,xmax,npoints);

ydata1 = zeros(npoints,1);
ydata2 = zeros(npoints,1);
for i=1:npoints;
    ydata1(i) = sin( pi * xdata(i)/xmax );
    ydata2(i) = cos( pi * xdata(i)/xmax );
end

% create a number for your figure
figure(1);

% plot x-y data: connected line in red
plot(xdata,ydata1,'r-'); hold on;

% plot x-y data: in blue showing only data points
plot(xdata,ydata2,'b.');

% Define a title for you plot
title('Plotting example of x-y data');

% Label the axis, including units of data being plotted
xlabel('position [m]');
ylabel('velocity [m/s]');

% Turn on the legend and give names to each line
legend('y = sin(x)','y = cos(x)')
