Sie sind auf Seite 1von 12

The University Of Faisalabad

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

>> plot(t,y);

Resulting Figure:
The following figure is shown when I pressed Enter.

The University Of Faisalabad


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;

>> plot(t,y);

Resulting Figure:
The following figure is shown when I pressed Enter.

The University Of Faisalabad


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

Resulting Figure:
The following figure is shown when I pressed Enter.

The University Of Faisalabad


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

Resulting Figure:
The following figure is shown when I pressed Enter.

The University Of Faisalabad


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

Resulting Figure:
The following figure is shown when I pressed Enter.

The University Of Faisalabad


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)

Resulting Figure:
The following figure is shown when I pressed Enter.

Das könnte Ihnen auch gefallen