0% found this document useful (0 votes)
16 views3 pages

Lab 3

The document provides instructions on how to generate basic signals like sawtooth wave, square wave, exponential signals, and sinusoidal signals in MATLAB. It includes examples of code to generate each of these signal types and defines the key parameters used. The lab tasks at the end assign generating specific signals based on the provided instructions.

Uploaded by

saba rasheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Lab 3

The document provides instructions on how to generate basic signals like sawtooth wave, square wave, exponential signals, and sinusoidal signals in MATLAB. It includes examples of code to generate each of these signal types and defines the key parameters used. The lab tasks at the end assign generating specific signals based on the provided instructions.

Uploaded by

saba rasheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

INSTITUTE OF BIOMEDICAL ENGINEERING & TECHNOLOGY

LIAQUAT UNIVERSITY OF MEDICAL AND HEALTH SCIENCES,


JAMSHORO
Subject: Signals & Systems Year: 3rd Term: 5th
Lab Handout – 03

Name: _________________________________ Roll No: ____________________

Score: __________ Signature of Tutor: ______________ Date:________________

To generate basic signals in MATlab

Lab Objective: To generate following signals in Matlab:


 Sawtooth wave
 Square wave
 Exponential Signals
 Sinusoidal signals

Sawtooth wave: To generate Sawtooth, following command will be used in Matlab:

A*sawtooth(fo*t + w);

Where
A= amplitude.
fo =fundamental frequency (measured in radians per second).
w=phase shift (measured in radians).

Example#01: Generate a sawtooth wave with amplitude of 1 unit, a frequency of 2 Hz or (4p


radians per second) and a phase shift of p /4 radian.

Program:
A=1;
fo=4*pi;
w=pi/4;
t=0:0.001:1;
y=A*sawtooth(fo*t+w);
plot(t,y);

Square wave: To generate Square, following command will be used in Matlab:

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);

Example #04: Plot the signal: x(t) = 5e-6t

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);

Example#06: Generation of cosine sequence:

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.

2. Plot the signal: y(t) = 3e5t

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

You might also like