Professional Documents
Culture Documents
A*sawtooth(fo*t + w);
Where
A= amplitude.
fo =fundamental frequency (measured in radians per second).
w=phase shift (measured in radians).
Program:
A=1;
fo=4*pi;
w=pi/4;
t=0:0.001:1;
y=A*sawtooth(fo*t+w);
plot(t,y);
A*square(fo*t + w);
Where
A= amplitude
fo =fundamental frequency (measured in radians per second)
w=phase shift (measured in radians).
Example # 02: Generate a square wave with amplitude 1, fundamental frequency 10p
radian per second (5 Hz) and phase of 5p
Program:
A=1;
fo=10*pi;
w=5*pi;
t=0:0.001:1;
sq=A*square(fo*t + w);
plot (t, sq)
axis ([0 1 -2 2])
Discrete Time Square wave: To generate a discrete time signal, we may use the stem command.
stem(n,x)
Example #03: Generate and plots the discrete time square wave, with frequency p/4 radians
per second, phase shift p/8 radians and amplitude = 1 unit.
Program:
A=1;
fo=pi/4;
w=pi/8;
n=-10:1:10;
x=A*square(fo*n + w);
stem(n, x)
Exponential Signals: There are two types of exponential signals: decaying exponentials and
growing exponentials. The MATLAB command for decaying exponential and growing
exponential is
B*exp(-a*t);
B*exp(a*t);
Program:
t=0:0.01:5;
b=5;
a=6;
y=b*exp(-a*t);
plot(t,y,'r-')
grid
Generation of Sine & Cosine sequence: To generate these two sequences use the following
commands:
sin(2*pi*t);
cos(2*pi*t);
13 | P a g e
Example#05: Generation of sine sequence:
Program:
t=0:0.01:pi;
y=sin(2*pi*t);
figure(2);
subplot(2,1,1);
plot(t,y);
Program:
t=0:0.01:pi;
z=cos(2*pi*t);
subplot(2,1,2);
plot(t,z);
ylabel(‘Amplitude’);
xlabel(‘n ’);
Lab Tasks:
1. Generate and plot the discrete time square wave, with frequency p/2 radians per
second, phase shift p/4 radians and amplitude = 3 unit.
3. Generate two Sine and two cosine waves with different color line on the same figure
by using subplot command.
14 | P a g e