% Script File: PlotSine.m % % Prints and plots a short table of sine evaluations. % % clc, clear n = 21; x = linspace(0,1,n); y = sin(2*pi*x); disp(' k x(k) sin(x(k))') disp('-----------------------') for k = 1:21, degrees = (k-1)*360/(n-1); disp(sprintf(' %2.0f %3.0f %6.3f',k,degrees,y(k))) end disp('x(k) is given in degrees.') disp(sprintf('One degree=%5.3e Radians', pi/180)) plot(x,y) title('The function y=sin(2*pi*x)') xlabel('x (in radians') ylabel('y') plot(x,y) title(sprintf('Plot using n = %d points.',n))