View
228
Download
0
Category
Preview:
Citation preview
8/17/2019 The University of Faisalabad
1/12
The University Of aisalabad
LAB NO. 1
Objective:
To generate a sinusoidal signal in matlab.
Softwares Used:
MATLAB R2011a
Procedure:
First of all I Open the Matlab Software.
I Open the window editor. I Write the code for sinusoidal signal.
Set the initial value of wave at 0.
Set the final value of wave at 10.
The Wave lies from 0 to 10.
Then Take the screenshot of the matlab coding.
The screenshot of matlab coding is shown.
Coding of Program:
>> t=0:0.1:10;
>> y=sin(t);
8/17/2019 The University of Faisalabad
2/12
>> plot(t,y);
Resulting Figure:
The following figure is shown when I pressed Enter.
8/17/2019 The University of Faisalabad
3/12
The University Of aisalabad
LAB NO. 02
Objective:
To generate a square wave from sin wave in matlab.
Software Used:
MATLAB R2011a
Procedure:
First of all I Open the Matlab Software.
The I Open the window editor.
After I Write the code for sinusoidal signal.
Set the initial value of wave at 0.
Set the final value of wave at 10.
The Wave lies from 0 to 10.
Then Add the 3rd
, 5th
, 7th
… 27th
Harmonics in the sin wave. The screenshot of matlab coding is shown.
Code Of Program
>> t=0:0.1:10;
>> y=sin(t);
>>
y=sin(t)+sin(3*t)/3+sin(5*t)/5+sin(7*t)/7+sin(9*t)/9+sin(11*t)/11+sin(13*t)/13+sin(15*t
)/15+sin(17*t)/17+sin(19*t)/19+sin(21*t)/21+sin(23*t)/23;
8/17/2019 The University of Faisalabad
4/12
>> plot(t,y);
Resulting Figure:
The following figure is shown when I pressed Enter.
8/17/2019 The University of Faisalabad
5/12
The University Of aisalabad
LAB NO.03
Objective:
How to generate a discrete sin wave in matlab.
Software Used:
MATLAB R2011a
Procedure:
First of all I Open the Matlab Software.
Then I Open the window editor.
I Write the code for discrete sinusoidal signal.
Set the initial value of wave at 0. Set the final value of wave at 10.
The Wave lies from 0 to 10.
For discrete signal use the command “stem” instead of “plot”.
The screenshot of matlab coding is shown.
Coding of Program:
>> t=0:0.1:10;
>> y=sin(t);
>> stem(t,y);
8/17/2019 The University of Faisalabad
6/12
Resulting Figure:
The following figure is shown when I pressed Enter.
8/17/2019 The University of Faisalabad
7/12
The University Of aisalabad
LAB NO.04
Objective:
To generate a sin wave using linspace command in matlab.
How to generate a sin wave in matlab using linspace command.
Software Used:
MATLAB R2011a
Procedure:
First of all I Open the Matlab Software.
Then I Open the window editor.
I Write the code for sinusoidal signal.
Set the initial value of wave at -5.
Again Set the final value of wave at 5.
The Wave lies from -5 to 5.
Code of program:
>> x=linspace(5,-5);
>>y=sin(x);
>>plot(x,y);
>>xlabel('-5 < x < 5');
8/17/2019 The University of Faisalabad
8/12
Resulting Figure:
The following figure is shown when I pressed Enter.
8/17/2019 The University of Faisalabad
9/12
The University Of aisalabad
LAB NO. 05
Objective:
To generate a sin wave using linspace command from -2π to 2π in matlab and label its
x-axis..
Tools Used:
MATLAB R2011a
PROCEDURE
First of all I Open the Matlab Software.
Then I Open the window editor.
I Write the code for sinusoidal signal.
Set the initial value of wave at -2π .
Again Set the final value of wave at 2π.
Then Label the x-axis from -2π to 2π.
Code of Program:
>> x=linspace(-2*pi,2*pi);
y=sin(x);
plot(x,y)
xlabel('-2/pi < x < 2/pi');
8/17/2019 The University of Faisalabad
10/12
Resulting Figure:
The following figure is shown when I pressed Enter.
8/17/2019 The University of Faisalabad
11/12
The University Of aisalabad
LAB NO. 06
Objective:
To study the noise signal in sinusoidal signal.
How to interperate the noise signal.
Software Used:
MATLAB R2011a
PROCEDURE
First of all I open the Matlab Software then I open the windows editor.
After this I Write the code for noise sinusoidal signal.
The screenshot of matlab coding is shown below.
Program Code:
>> N=200;
>> T=0.05;
>> t=(0:N-1)*T;
>> s=sin(2*pi*120*t);
>> plot(t,s)
8/17/2019 The University of Faisalabad
12/12
Resulting Figure:
The following figure is shown when I pressed Enter.
Recommended