14-02-2013, 04:45 PM
GENERATION OF WAVEFORMS
GENERATION OF WAVEFORMS.docx (Size: 32.81 KB / Downloads: 19)
PROGRAM:
%CONTINUOUS WAVEFORM GENERATION
%using MATLAB functions
clc;%clears all input and output from the Command Window display
clear all;%Removes all variables, functions from memory,
%leaving the workspace empty
%sinusoidal waveform
%sine wave
f=input('Enter the frequency : ');%f-frequency
a=input('Enter the desired amplitude value : ');%a-amplitude
t=-10:0.01:10;%t-time
x=a*sin(2*pi*f*t);%x-sine wave signal
%Plotting of sine wave
subplot(4,1,1);%subplot(m,n,p) creates an axes in the pth pane of a
%figure divided into an m-by-n matrix of rectangular panes
plot(t,x,'k','linewidth',1.5);%Linear 2-D plot with 'k' representing black
%colour plot with width 1.5
xlabel('t(sec)');%Label the x-axis
ylabel('x(t)');%Label the y-axis
title('SINE WAVE GENERATION');%Add title to current axes
grid on;%layout grid that can aid the hand layout of objects
%displayed in the figure
%cosine wave
y=a*cos(2*pi*f*t);%y-cosine wave signal
%Plotting of cosine wave
subplot(4,1,2);
plot(t,y,'k','linewidth',1.5);
xlabel('t(sec)');
ylabel('y(t)');
title('COSINE WAVE GENERATION');
grid on;
%square wave
z=a*square(2*pi*f*t);%z-square wave signal
%Plotting of square wave
subplot(4,1,3);
plot(t,z,'k','linewidth',1.5);
xlabel('t(sec)');
ylabel('z(t)');
title('SQUARE WAVE GENERATION');
grid on;
%sawtooth wave
w=sawtooth(2*pi*f*t);%w-sawtooth wave signal
%Plotting of sawtooth wave
subplot(4,1,4);
plot(t,w,'k','linewidth',1.5);
xlabel('t(sec)');
ylabel('w(t)');
title('SAWTOOTH WAVE GENERATION');
grid on;
INPUT:
Enter the frequency : 0.75
Enter the desired amplitude value : 1