Professional Documents
Culture Documents
Aim: Using the MATLAB functions plot sawtooth, square, sine, cosine, rectangular pulse, triangular pulse, sinc function and signum function. The time axis should span t = -5 to 5. Give frequency, amplitude and width(if necessary) user define value. Program: clc; clear all; close all; a= input('enter the amplitude'); f=input('enter the freq.'); t=-10:0.0001:10; w= input('enter the width'); % sine s=a*sin(2*pi*f*t); subplot(2,2,1); plot(t,s); grid on; axis([-10 10 -a-1 a+1]) title('sine wave'); xlabel ('time'); ylabel ('Amplitude');
Page 1
% cosine c=a*cos(2*pi*f*t); subplot(2,2,2); plot(t,c); grid on; axis([-10 10 -a-1 a+1]) title('cosine wave'); xlabel ('time'); ylabel ('Amplitude');
% sawtooth saw=a*sawtooth(2*pi*f*t); subplot(2,2,3); plot(t,saw); grid on; axis([-10 10 -a-1 a+1]) title('sawtooth wave'); xlabel ('time'); ylabel ('Amplitude');
subplot(2,2,4); plot(t,squ); grid on; axis([-10 10 -a-1 a+1]) title('square wave'); xlabel ('time'); ylabel ('Amplitude'); figure();
% sinc snc=a*sinc(2*pi*f*t); subplot(2,2,1); plot(t,snc); grid on; axis([-10 10 -a-1 a+1]) title('sinc wave'); xlabel ('time'); ylabel ('Amplitude');
plot(t,trp); grid on; axis([-10 10 -a-1 a+1]) title('triangular wave'); xlabel ('time'); ylabel ('Amplitude');
% rectangular rec=a*rectpuls(t,w); subplot(2,2,3); plot(t,rec); grid on; axis([-10 10 -a-1 a+1]) title('rectangular wave'); xlabel ('time'); ylabel ('Amplitude');
% signam su=a*sign(t); subplot(2,2,4); plot(t,su); grid on; axis([-10 10 -a-1 a+1]) title('signam wave'); PRADEEP BORSE /09EC004/DSP MANUAL/CGPIT Page 4
Page 5
Figure :
Page 6
Page 7