0% found this document useful (0 votes)
52 views11 pages

Lab Assignment: (Generation of Signals Using MATLAB)

The document describes how to generate 10 different types of signals using MATLAB: 1) sine function, 2) cosine function, 3) unit-step function, 4) ramp function, 5) triangle function, 6) complex function, 7) exponential function, 8) rectangular function, 9) square wave, and 10) sawtooth function. For each signal type, the document provides the MATLAB code to generate the signal and includes an example figure of the plotted signal.

Uploaded by

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

Lab Assignment: (Generation of Signals Using MATLAB)

The document describes how to generate 10 different types of signals using MATLAB: 1) sine function, 2) cosine function, 3) unit-step function, 4) ramp function, 5) triangle function, 6) complex function, 7) exponential function, 8) rectangular function, 9) square wave, and 10) sawtooth function. For each signal type, the document provides the MATLAB code to generate the signal and includes an example figure of the plotted signal.

Uploaded by

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

[Generation Of Signals Using MATLAB]

LAB ASSIGNMENT

1
LAB ASSIGNMENT

SUBMITTED TO:
ENGR MUHAMMAD LIYAQAT
SUBMITTED BY:

HAFIZ MUHAMMAD NOUMAN (2019-EE-35)

COURSE INSTRUCTOR:
DR MUHAMMAD ABRAR

SESSION:
2019-2023

SEMESTER:
5th

SUBJECT :
SIGNAL & SYSTEM (EE-501)

2
TOPIC:
GENERATION OF SIGNALS USING MATLAB

Department :
ELECTRICAL ENGINEERING BZU, MULTAN

3
Table Of Contents

Generation of Signals……………………………….5-10

List Of Figures

Figure 1.1….…………………………………………5

Figure 2.1…………………………………………….6

Figure 3.1……………………………………………..6

Figure 4.1……………………………………………..7

Figure 5.1……………………………………………..8

Figure 6.1..……………………………………………8

Figure 7.1……………………………………………..9

Figure 8.1……………………………………………10

Figure 9.1……………………………………………11

Figure 10.1…………………………………………..11

4
Generation Of Signals On MATLAB

1. Sine Function:
It is also known as sinusoidal signal. In MATLAB it can be plotted as given:

Code:
 t=-35:0.1:35; ‘ creating limit for function.’
 y = 35*sin(t); ‘ initialize the sine function.’
 plot(t,y) ‘ plotting the sine function.’
 xlabel 'input' ‘ labeling.’
 ylabel 'output' ‘ labeling.’
 title 'Sine Wave' ‘assigning Title.’
 grid on

Figure:1.1 Sine Function.

2. Cos Function:
It is also known as sinusoidal signal. In MATLAB it can be plotted as given:

Code:
 t=-35:0.1:35; ‘ creating limit for function.’
 y=35*cos(t); ‘ initialize the cos function.’
 plot(t,y) ‘ plot the cos function.’
 xlabel 'input' ‘ labeling.’
 ylabel 'output' ‘ labeling.’
 title 'Cos Wave' ‘assigning Title.’
 grid on ‘open the grid lines of graph ’

5
Figure:2.1 Cos Function.

3. Unit-Step Function:
Unit step function has a constant amplitude of unity for the ero or positive values of
time t. Whereas it has a zero or negative values of t.

Code:
 t=-35:35; ‘creating limit for function.’
 unitstep = t>=35; ‘creating unitstep function.’
 plot(t,[unitstep]) ‘plotting unitstep function.’
 plot(t,[35*unitstep]) ‘setting function according to roll number.’
 xlabel 'input' ‘ labeling.’
 ylabel 'output' ‘ labeling.’
 title 'Unit Step Wave' ‘assigning Title.’
 grid on ‘open the grid lines of graph ’

Figure:3.1 Unit-step Function.

6
4. Ramp Function:
A ramp signal has values increase linearly with sample number n. It is denoted by r(t).

Code:
 t=-35:35; ‘creating limit for function.’
 unitstep=t>=0; ‘creating unitstep function.’
 ramp=t.*unitstep; ‘creating ramp function.’
 plot(t,[ramp]) ‘plotting ramp function.’
 plot(t+35,[ramp]) ‘scaling ramp function.’
 grid on

Figure:4.1 Ramp Function.

5. Triangle Function:
It is also known as Hat or Tent function is a function whose graph takes the shape of
triangle.

Code:
 t=-35:0.1:35; ‘creating limit for function.’
 f=0.05; ‘assigning value of frequency.’
 x=35*sawtooth(2*pi*f*t,0.1); ‘creating triangle function.’
 plot(t,[x]) ‘plotting triangle function.’
 xlabel 'input'
 ylabel 'output'
 title 'Triangle Wave'
 grid on

7
Figure:5.1 Triangle Function.

6. Complex Function:
The continuous time complex exponential signal is of the following form:

Code:
 t=-35:35; ‘creating limit for function.’
 y=35*exp((4+5i).*t); ‘creating complex function.’
 plot(t,[y]) ‘ploting complex function.’
 xlabel 'input'
 ylabel 'output'
 title 'Triangle Wave'
 grid on

Figure:6.1 Complex Function.

8
7. Exponential Function:
The discrete time complex exponential signal is of the following form:

Code:
 t=-35:35; ‘creating limit for function.’
 z=35*exp(t); ‘creating exponential function.’
 plot(t,z) ‘ploting exponential function.’
 xlabel 'input'
 ylabel 'output'
 title 'Exponential Wave'
 grid on

Figure:7.1 Exponential Function.

8. Rectangular Function:
A rectangular pulse having its amplitude and time duration is given as follow:

Code:
 t1=-1:0.01:-0.5; ‘creating 1st interval for function.’
 t2=-0.5:0.01:0; ‘creating 2nd interval for function.’
 t3=0:0.01:1; ‘creating 3rd interval for function.’
 t4=1:0.01:1.5; ‘creating 4th interval for function.’
 t5=1.5:0.01:2; ‘creating 5th interval for function.’
 t6=2:0.01:2.5; ‘creating 6th interval for function.’
 t=[t1 t2 t3 t4 t5 t6]; ‘time limit’
 x1=zeros(size(t1)); ‘Amplitude in 1st column.’
 x2=ones(size(t2)); ‘Amplitude in 2nd column.’
 x3=zeros(size(t3)); ‘Amplitude in 3rd column.’
 x4=zeros(size(t4)); ‘Amplitude in 4th column.’
 x5=ones(size(t5)); ‘Amplitude in 5th column.’
 x6=zeros(size(t6)); ‘Amplitude in 6th column.’
 x=[x1 x2 x3 x4 x5 x6]; ‘overall amplitude.’

9
 plot(t,[35*x]) ‘ploting Rectangular function.’
 xlabel 'input'
 ylabel 'output'
 title 'Rectangular Wave'
 grid on

Figure:8.1 Rectangular Function.

9. Square Wave:
A square pulse having its amplitude and time duration is given as follow:

Code:
 t=-35:35; ‘creating limit for function.’
 x=35*square(t); ‘creating Square function.’
 plot(t,x) ‘ploting Square function.’
 xlabel 'input'
 ylabel 'output'
 title 'Square Wave'
 grid on

10
Figure:9.1 Square Function.

10. Sawtooth Function:


A sawtooth pulse having its amplitude and time duration is given as follow:

Code:
 t=-35:35; ‘creating limit for function.’
 x=35*sawtooth(t); ‘creating Sawtooth function.’
 plot(t,x) ‘ploting Sawtooth function.’
 xlabel 'input'
 ylabel 'output'
 title 'Sawtooth Wave'
 grid on

Figure:10.1 Sawtooth Function.

11

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy