Professional Documents
Culture Documents
Setup: A very basic, unembellished routine that may be entered either in the command
window or as an m-file is:
a=0:10:720;
A=sind(a);
B=cosd(a);
plot(a,A,a,B)
But a better routine would include comments and more attention to the generated plot
(i.e. labeling of axes, a legend, etc.).
% MLP0101
%
% Plot sin(a) & cos(a) for 0 < a < 720 degrees
%
% 1/11/06 Wentworth
%
% Variables
% a angle in degrees
% A sind(a), accepts argument in degrees
% B cosd(a)
clc;clear;
% calculation
a=0:10:720; %uses 10 degree steps
A=sind(a);
B=cosd(a);
% generate plot
plot(a,A,'-k',a,B,'--b')
legend('sin(a)','cos(a)')
grid on
xlabel('angle a(degrees)')
ylabel('y')
title('Problem 1.1')
0.6
0.4
0.2
0
y
-0.2
-0.4
-0.6
-0.8
-1
0 100 200 300 400 500 600 700 800
angle a(degrees)
Figure P0101