SDITW, NANDYAL DEPT.
OF ECE
BASIC SIMULATION
LAB MANUAL
[Link](ECE), I- SEM
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGG.
SYAMALADEVI INSTITUTE OF TECHNOLOGY FOR WOMEN
Approved by A.I.C.T.E., New Delhi, Affiliated to JNT University, Anantapur.
NANDYAL- 518501, KURNOOL (Dt.), A.P.
1
SDITW, NANDYAL [Link] ECE
LIST OF EXPERIMENTS
[Link] Name of The Experiment
1. Basic operations on matrices
2. Generation of various signals and sequences
3. Operations on signals and sequences
4. Finding the even and odd parts of signal or sequence
5. Convolution between signals and sequences
6. Autocorrelation and cross correlation between signals and
sequences
7. Verification of Linearity and time invariance properties of a
given continuous and discrete system
8. Computation of unit sample, unit step and sinusoidal response
of the given LTI system and verifying its Physical Reliability
and stability properties
9. Gibbs phenomenon
10. Finding the Fourier transform of a given signal and plotting its
magnitude and phase spectrum
11. Waveform Synthesis using Laplace transform
12. Locating Zeros and poles, and plotting the pole-zero maps in S-
plane and Z-plane for the given transfer function
13. Generation of Gaussian noise(Real and Complex)
14. Sampling theorem Verification
15. Removal of noise by autocorrelation/cross correlation in a given
signal corrupted by noise
16. Impulse response of a raised cosine filter
17. Verification of Weiner-Khinchine Relation
18. Checking a random process for stationary in wide sense
2
SDITW, NANDYAL [Link] ECE
INTRODUCTION
1. MATLAB (Matrix Laboratory), a product of Math works, is a scientific
software package designed to provide integrated numeric computation and
graphics visualization in high-level programming language.
2. MATLAB program consists of standard and specialized toolboxes allowing
users to take advantage of the matrix algorithm based on LINPACK1 and
EISPACK2 projects.
3. MATLAB offers interactive features allowing the users great flexibility in the
manipulation of data and in the form of matrix arrays for computation and
visualization.
4. MATLAB inputs can be entered at the "command line" or from "mfiles",
which contains a programming-like set of instructions to be executed by
MATLAB.
5. In the aspect of programming, MATLAB works differently from
FORTRAN, C, or Basic, e.g. no dimensioning required for matrix arrays and
no object code file generated.
6. MATLAB offers some standard toolboxes and many optional toolboxes (at
extra cost, of course!) such as financial toolbox and statistics toolbox.
7. Users may create their own toolboxes consisted of "mfiles" written for
specific applications.
8. The original version of MATLAB was written in FORTRAN but later was
rewritten in C.
9. You are encouraged to use MATLAB's on-line help files for functions and
commands associated with available toolboxes.
10. MATLAB consists of a collection of toolboxes. These toolboxes contain
library files called M-Files, which are also functions or command names,
executable from the Command window.
3
SDITW, NANDYAL [Link] ECE
Basic Matrix Operations: This is a demonstration of some aspects of the
MATLAB language. First, let's create a simple vector with 9 elements called
a. a = [1 2 3 4 6 4 3 4 5]
a=
1 2 3 4 6 4 3 4 5
Now let's add 2 to each element of our vector, a, and store the result in a new
vector. Notice how MATLAB requires no special handling of vector or
matrix math.b = a + 2
b=
3 4 5 6 8 6 5 6 7
Creating graphs in MATLAB is as easy as one command. Let's plot the
result of our vector addition with grid [Link](b)
grid on
MATLAB can make other graph types as well, with axis [Link](b)
xlabel('Sample #')
ylabel('Pounds')
MATLAB can use symbols in plots as well. Here is an example using stars
to mark the points. MATLAB offers a variety of other symbols and line
types. plot(b,'*')
axis([0 10 0 10])
One area in which MATLAB excels is matrix computation. Creating a
matrix is as easy as making a vector, using semicolons (;) to separate the
rows of a matrix.A = [1 2 0; 2 5 -1; 4 10 -1]
A=
1 2 0
2 5 -1
4 10 -1
We can easily find the transpose of the matrix A. B = A'
B=
1 2 4
2 5 10
0 -1 -1
4
SDITW, NANDYAL [Link] ECE
Now let's multiply these two matrices together. Note again that MATLAB
doesn't require you to deal with matrices as a collection of numbers.
MATLAB knows when you are dealing with matrices and adjusts your
calculations accordingly. C = A * B
C=
5 12 24
12 30 59
24 59 117
Instead of doing a matrix multiply, we can multiply the corresponding
elements of two matrices or vectors using the .* operator.C = A .* B
C=
1 4 0
4 25 -10
0 -10 1
Let's find the inverse of a matrix ...X = inv(A)
X=
5 2 -2
-2 -1 1
0 -2 1
... and then illustrate the fact that a matrix times its inverse is the identity
matrix.I = inv(A) * A
I=
1 0 0
0 1 0
0 0 1
MATLAB has functions for nearly every type of common matrix
calculation. There are functions to obtain eigenvalues ...eig(A)
ans =
3.7321
0.2679
5
SDITW, NANDYAL [Link] ECE
1.0000
... as well as the singular value [Link](A)
ans =
12.3171
0.5149
0.1577
The "poly" function generates a vector containing the coefficients of the
characteristic polynomial. The characteristic polynomial of a matrix A is p
= round(poly(A))
p=
1 -5 5 -1
We can easily find the roots of a polynomial using the roots function. These
are actually the eigenvalues of the original [Link](p)
ans =
3.7321
1.0000
0.2679
MATLAB has many applications beyond just matrix computation. To
convolve two vectors ...q = conv(p,p)
q=
1 -10 35 -52 35 -10 1
... or convolve again and plot the result.r = conv(p,q)
plot(r);
r=
1 -15 90 -278 480 -480 278 -90 15 -1
6
SDITW, NANDYAL [Link] ECE
1. BASIC OPERATIONS ON MATRICES
Defining Matrices
Defining a matrix is similar to defining a vector. To define a matrix, you can treat it like
a column of row vectors (note that the spaces are required!):
>> A = [ 1 2 3; 3 4 5; 6 7 8]
A =
1 2 3
3 4 5
6 7 8
You can also treat it like a row of column vectors:
>> B = [ [1 2 3]' [2 4 7]' [3 5 8]']
B =
1 2 3
2 4 5
3 7 8
>> v = [0:2:8]
v =
0 2 4 6 8
Matrix Functions
Once you are able to create and manipulate a matrix, you can perform many standard
operations on it. For example, you can find the inverse of a matrix. You must be careful,
however, since the operations are numerical manipulations done on digital computers. In
the example, the matrix A is not a full matrix, but matlab's inverse routine will still return
a matrix.
>> inv(A)
7
SDITW, NANDYAL [Link] ECE
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 4.565062e-18
ans =
1.0e+15 *
-2.7022 4.5036 -1.8014
5.4043 -9.0072 3.6029
-2.7022 4.5036 -1.8014
By the way, Matlab is case sensitive. This is another potential source of problems when
you start building complicated algorithms.
>> inv(a)
??? Undefined function or variable a.
Other operations include finding an approximation to the eigen values of a matrix. There
are two versions of this routine, one just finds the eigen values, the other finds both the
eigen values and the eigen vectors. If you forget which one is which, you can get more
information by typing help eig at the matlab prompt.
>> eig(A)
ans =
14.0664
-1.0664
0.0000
>> [v,e] = eig(A)
v =
-0.2656 0.7444 -0.4082
-0.4912 0.1907 0.8165
-0.8295 -0.6399 -0.4082
e =
14.0664 0 0
0 -1.0664 0
0 0 0.0000
8
SDITW, NANDYAL [Link] ECE
>> diag(e)
ans =
14.0664
-1.0664
0.0000
Matrix Operations
There are also routines that let you find solutions to equations. For example, if Ax=b and
you want to find x, a slow way to find x is to simply invert A and perform a left multiply
on both sides (more on that later). It turns out that there are more efficient and more
stable methods to do this (L/U decomposition with pivoting, for example). Matlab has
special commands that will do this for you.
Before finding the approximations to linear systems, it is important to remember that if A
and B are both matrices, then AB is not necessarily equal to BA. To distinguish the
difference between solving systems that have a right or left multiply, Matlab uses two
different operators, "/" and "\". Examples of their use are given below. It is left as an
exercise for you to figure out which one is doing what.
>> v = [1 3 5]'
v =
1
3
5
>> x = A\v
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 4.565062e-18
x =
1.0e+15 *
1.8014
-3.6029
1.8014
>> x = B\v
9
SDITW, NANDYAL [Link] ECE
x =
2
1
-1
>> B*x
ans =
1
3
5
>> x1 = v'/B
x1 =
4.0000 -3.0000 1.0000
>> x1*B
ans =
1.0000 3.0000 5.0000
Once Matlab's initializing process is completed, a Matlab desktop
environment will appear providing a set of subwindows, a.k.a browsers.
In this desktop environment you may define variables, manage files
and objects, execute programs, and view command history.
A typical Matlab desktop is shown below.
10
SDITW, NANDYAL [Link] ECE
Workspace window displays the defined variables. You may also list all
defined variables in a Matlab session by issuing the command who in
Command Window. The "traditional" Command window is where the
user normally defines variables and enters Matlab pre-defined
functions. You may close, restore, and resize any of these windows.
Setting Path...
M files called from the Command Window are automatically located by
Matlab, as long as the file's path is defined.
To define the path, select:
File > Set Path...
A window like one shown below will pop up. Click on Add Folder...
button then browse through the directories to locate the desired m file.
11
SDITW, NANDYAL [Link] ECE
Defining Variables...
One of the easy ways to learn MATLAB is to understand how MATLAB
handles matrices. Think in terms of arrays and vectors when you work
with MATLAB. For example, an array of data A = 1, 0, 9, 11, 5 is a 1x5
matrix, and a scalar number 9 is an 1x1 matrix. To store the array A in
MATLAB, at the command prompt >> (in Command window), enter:
MATLAB will display or echo your input:
To suppress the echo, add a ";" at the end of the input line.
To verify the size of the input array or matrix, use the command "size"
as shown below:
which verifies the dimension of matrix A as 1x5 (one row and five
columns).
12
SDITW, NANDYAL [Link] ECE
In MATLAB, rows are separated by ";" and columns are separated by
",". For example, a 3x5 matrix B with the following elements:
first row: 1, 0, 9, 4, 3
second row: 0, 8, 4, 2, 7
third row: 14, 90, 0, 43, 25
would be entered in MATLAB as follow:
Note that you may use a space in place of the comma in separating
the column entries.
You may add, subtract, multiply, and divide matrices with simple
operation in MATLAB. Please keep in mind of the rules concerning
matrix operations such as dimensional compatibility issue, e.g., you
may not pre-multiply a 2x3 matrix with a 4x2 matrix - the dimensions
must agree.
You may extract a certain group or element from an existing matrix.
Say you wish to create a new array C from the second row of matrix B.
Specify the row number and ":" for all columns in that row as shown
below:
Similarly, You may also form a matrix from the element of an existing
matrix:
13
SDITW, NANDYAL [Link] ECE
Here, a square matrix D has been created from the specified elements
of matrix B.
You may also delete rows and columns from a matrix using a pair of
square brackets. For example, to delete the third column of matrix B,
you simply enter
and MATLAB will return:
Note that the column 3 is excluded.
Alternately, you may define these variables (matrices) by clicking on
the New Variable icon in Workspace browser as shown below.
Once a variable name is entered, you may double click on the icon
associated with the variable name (in Workspace browser) to bring up
the Array Editor. From the Array Editor, you may enter the values as
you would in a typical spreadsheet program like Excel.
14
SDITW, NANDYAL [Link] ECE
You may create a new variable from selected elements of the existing
array by highlighting the group of elements you wish to use, then right-
click with the cursor pointing in the selected area to bring up the
context menu. Select the Create Variable from Selection choice.
Matlab will assign an "unnamed" label to your new varible. To modify
this, right-click the unnamed variable and select Rename from the
pop-up menu.
Data from the Array Editor browser could be exchanged with
OpenOffice Calc spreadsheet program via the clipboard. (OpenOffice
works fine for me in both Windows and Linux environments. I don't use
Excel but I believe the file I/O interface with Excel is supported by
Matlab 7 and R2006a).
Working with Arrays...
MATLAB treats arithmetic operations on arrays in an element-by-
element manner. This operation is accomplished by including a dot or
a period before the arithmetic operator such as multiplication, division,
etc. The table below gives a list of such operators with examples of
how these operators are being used.
For examples in the table below, the following matrices are used:
15
SDITW, NANDYAL [Link] ECE
Operatio Example (MATLAB actual inputs and
Description
n outputs)
+ Addition
- Substraction
* Multiplication
Element-by-element
multiplication.
Note that this is
.*
different from
multiplication of two Note that this is not the same as C
matrices. = A*B
16
SDITW, NANDYAL [Link] ECE
Right matrix division.
/
Dividing matrix B
into matrix A
Left matrix division.
Dividing A into B.
\ This is equivalent to
inv(A)*B. Note that
X = C is the solution
to A*X=B
Element-by-element
division
./ note that D(2,1) is
undefined due to the
zero at B(2,1)
Element-by-element
left [Link] that
left division in this
particular example
.\
means elements of B
divided by the
corresponding
elements of A.
Element-by-element
.^
power
Transposing a matrix in MATLAB involves a simple prime notation ( ' )
after the defined matrix as shown below:
Example:
17
SDITW, NANDYAL [Link] ECE
Sorting columns and rows follow the syntax: B=sort(A,dim), where
dim is the dimension of the matrix with the value 1 for column; 2 for
row. Matrix A is the variable specified by the user.
Example:
Sorting columns:
Note that without dim being specified, the default value is 1. The
default setting is ascending order. The variable name of the sorted
matrix can be omitted if no needed.
Sorting column in descending order:
Sorting row in descending order
18
SDITW, NANDYAL [Link] ECE
The inverse of matrix A can be obtained with the command:
Eigenvalues and Eigenvectors can easily be obtained with the
command [V,E]=eig(matrix name):
where matrix V consists of Eigenvectors . The corresponding
Eigenvalues are shown in matrix E. Eigen values alone can be obtained
without the notation "[V,E]":
2) Generation of various signals and sequences
%sin signal
t=-1:.01:1;
x=sin(2*pi*t);
plot(t,x);
xlabel('time');
ylabel('amplitude')
19
SDITW, NANDYAL [Link] ECE
%exponential signal
t=-1:.01:1;
x=exp(2*t);
plot(t,x);
xlabel('time');
ylabel('amplitude')
%sawtooth signal
t=-20:.01:20;
x=sawtooth(t);
plot(t,x);
xlabel('time');
ylabel('amplitude')
20
SDITW, NANDYAL [Link] ECE
%square signal
t=-20:.01:20;
x=square(t);
plot(t,x);
xlabel('time');
ylabel('amplitude');
axis([-10 10 -2.5 2.5])
\
%sinc signal
t=-20:.01:20;
x=sinc(t);
plot(t,x);
xlabel('time');
ylabel('amplitude');
axis([-10 10 -2.5 2.5])
21
SDITW, NANDYAL [Link] ECE
%rectangular signal
t=-20:.01:20;
x=rectpuls(t);
plot(t,x);
xlabel('time');
ylabel('amplitude');
axis([-10 10 -2.5 2.5])
%triangular signal
t=-20:.01:20;
x=tripuls(t);
plot(t,x);
xlabel('time');
ylabel('amplitude');
axis([-10 10 -2.5 2.5])
22
SDITW, NANDYAL [Link] ECE
%signum function
t=-20:.01:20;
x=sign(t);
plot(t,x);
xlabel('time');
ylabel('amplitude');
axis([-10 10 -2.5 2.5])
%unit step sequence
N=31;
x=ones(1,N);
n=0:1:N-1;
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('unit step sequence ')
23
SDITW, NANDYAL [Link] ECE
%generation of impulse sequence sequences
n=-4:1:4;
x=[zeros(1,4),1,zeros(1,4)];
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('impulse sequence')
%generation of unit ramp sequence sequences
n=0:1:10;
x=n;
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('impulse sequence')
24
SDITW, NANDYAL [Link] ECE
%Program for the generation of circle
theta=linspace(0,2*pi,100);
x=cos(theta);
y=sin(theta);
plot(x,y,'go');axis('equal');
xlabel('x(n)');ylabel('y(n)');
title('circle')
RESULT:
3) Operations on signals and sequences:
%addition of two sinusoidal sequences
N=31;
n=0:1:N-1;
x=sin(.5*pi*n)+sin(.25*n);
stem(n,x);
25
SDITW, NANDYAL [Link] ECE
xlabel('time');
ylabel('amplitude');
title('addition of two sinusoidal sequences')
RESULT:
4) Convolution of two sequences
x = [1,2,3,4,5,6];
n1 = length(x);
h = [6,5,4,3,2,1];
n2 = length(h);
26
SDITW, NANDYAL [Link] ECE
y = conv(x, h);
n = 0:(n1 + n2 - 2); % index for convolution output
stem(n, y);
xlabel('n');
ylabel('y(n)');
title('Convolution of two sequences');
RESULT:
5) CROSS CORRELATION
x=input('enter the 1st sequence');
h=input('enter the 2nd sequence');
y=xcorr(x,h);
subplot(3,1,1);
stem(x);
27
SDITW, NANDYAL [Link] ECE
ylabel('amplitude');
xlabel('(a)n');
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('(b)n');
subplot(3,1,3);
stem(fliplr(y));
ylabel('amplitude');
xlabel('(c)n');
disp('The resultant is');y
RESULT:
enter the 1st sequence[2 3 4 5 6]
enter the 2nd sequence[3 4 5 6 7]
The resultant is
y=
Columns 1 through 7
14.0000 33.0000 56.0000 82.0000 110.0000 86.0000 62.0000
Columns 8 through 9
39.0000 18.0000
6. %plot the square wave and hence verify Gibb's phenomena using
first 10 terms of Fourier series.
clear all;
T=input('enter the time period of the square wave');
n1=input('enter the number of cycles to be plotted');
n=input('enter the number of harmonics to be considered apart from dc');
28
SDITW, NANDYAL [Link] ECE
k=n1*T/2;
i=0;
for t=-k:k/100:k
x=0;
for j=1:2:(2*n-1)
xnew=x+(4*(cos((t*2*pi*j/T)-(pi*floor(j/2))))/(j*pi));
x=xnew;
end
i=i+1;
p(:,i)=x;
end
t=-k:k/100:k;
plot(t,p)
enter the time period of the square wave1
enter the number of cycles to be plotted5
enter the number of harmonics to be considered apart from dc10
RESULT:
7. %To verify sampling theorem
clear all;
close all;
t=-100:.01:100;
fm=.02;
x=cos(2*pi*t*fm);
29
SDITW, NANDYAL [Link] ECE
subplot(2,2,1);
plot(t,x);
xlabel('time in sec');
ylabel('x(t)');
title('continuous time signal');
fs1=.02;
n=-2:2;
x1=cos(2*pi*fm*n/fs1);
subplot(2,2,2);
stem(n,x1);
hold on;
subplot(2,2,2);
plot(n,x1,':');
title('Discrete time signal x(n) with fs<2fm');
xlabel('n');
ylabel('x(n)');
fs2=.04;
n1=-4:4;
x2=cos(2*pi*fm*n1/fs2);
subplot(2,2,3);
stem(n1,x2);
hold on;
subplot(2,2,3);
plot(n1,x2,':');
title('Discrete time signal x(n) with fs=2fm');
xlabel('n');
ylabel('x(n)');
n2=-50:50;
fs3=.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(2,2,4);
stem(n2,x3);
hold on;
subplot(2,2,4);
plot(n2,x3,':');
xlabel('n');
ylabel('x(n)');
title('Discrete time signal x(n) with fs>2fm');
30
SDITW, NANDYAL [Link] ECE
RESULT:
31
SDITW, NANDYAL [Link] ECE
8.% frequency response of first order system
b=[1];
a=[1,-.8];
w=0:.01:2*pi;[h]=freqz(b,a,w);
subplot(2,1,1);
plot(w/pi,abs(h));
title('frequency responce of first order systemh(n)=0.8^nu(n)');
xlabel('normalised frequency ');
ylabel('magnetude');
subplot(2,1,2);
plot(w/pi,angle(h));
xlabel('normalised frequency ');
ylabel('phase in radians');
32
SDITW, NANDYAL [Link] ECE
9. a. % To compute the impulse response of the digital filter
clear all;
close all;
b=input('enter the numerator coefficients');
a=input('enter the denominator coefficients');
[H,T]=impz(b,a);
stem(T,H);
xlabel('n');
ylabel('h(n)')
enter the numerator coefficients[1]
enter the denominator coefficients[1 -.7 .12]
RESULT:
0.9
0.8
0.7
0.6
9. b.h(n)
%Frequency
0.5
response of a given system
b=[1 , .9];
0.4
a=[1 ,.4];
0.3
w=0:.01:pi;
[h]=freqz(b,a,w);
0.2
subplot(2,1,1);
plot(w/pi,abs(h));xlabel('freq');ylabel('mag');
0.1
subplot(2,1,2);
plot(w/pi,angle(h));
0
xlabel('freq');ylabel('phase');
0 1 2 3 4 5 6 7 8 9
n
33
SDITW, NANDYAL [Link] ECE
RESULT:
10.% Program for computing discrete Fourier transforms (Stable)
clear all;
close all;
b=input('enter the denominator coefficients of the filter');
k=poly2rc(b);
knew=fliplr(k);
s=all(abs(knew),1);
if(s==1)
disp(' "stable system" ');
else
disp (' "Nonstable system" ');
34
SDITW, NANDYAL [Link] ECE
end;
RESULT:
[Link] for Verification of linearity of a discrete time system
CLC;
Clear all;
X1=input(‘type the sample of x1’);
X2=input(‘type the sample of x2’);
If(length(x1)~=length(x2))
Disp(’error :length of x1 and x2 are different’);
Return;
End;
H=input(‘type the sample of h’);
35
SDITW, NANDYAL [Link] ECE
N=length( x1)+length(h)-1;
Disp(‘length of the output signal will be’);
Disp(N);0-pp+
A1=input(‘the scale factor of a1 is’);
A2=input(‘the scale factor of a2 is’);
X=a1*x1+a2*x2;
Y01=conv(x,h);
Y1=conv(x1,h);
Y1s=a1*y1;
Y2=conv(x2,h);
y2s=a2*y2;
Y02=y1s+y2s;
Disp(‘input signal x1 is’); disp(x1);
Disp(‘input signal x2 is’); disp(x2);
Disp(‘output signal y01 is’); disp(y01);
Disp(‘output signal y02 is’); disp(y02);
If(y01==y02)
Disp(‘the system is linear’);
Else
Disp(‘the system is non-linear’);
End;
Result:
[Link] plot the DFT of Arbitrary Signal x(n) using the built function
fft and plot the magnitude and phase spectrum.
CLC;
clear all;
F=100;
FS=1000;
TS=1/FS;
N=1024
n= [0:N-1]*TS;
= 0:(N-1)*TS;
X=0.8*cos(2*pi*f*n)
36
SDITW, NANDYAL [Link] ECE
Figure:
Plot(n,x);grid;
Axis([0 0.05 -1 1])
Title(‘cosine signal of the frequency f’);
Xlabel(‘time n’);
Xlabel(‘x(n)’);
X(k)=fft(x,N);
K=0:N-1.
Figure:
Xmag=abs(xk);
Subplot(2,1,1);plot(k,xmag)
Titlle(‘mag of fourier transform’);
Xlabel(‘frequency index x’);
Ylabel(‘magnitude’);
Subplot(2,1,2);plot(k,Angle(xk));
Grid;
Title(‘phase of the fourier transform’);
Xlabel(‘frequency(k)’);
Ylabel(‘Angle’);
37
SDITW, NANDYAL [Link] ECE
Result:
-
[Link] a program to display the characteristic of Random Signal
generator.
Clc;
clear all;
X1=randn(1,5000);
X2=randn(1,5000);
Figure;plot(x1,x2,’:’);
Title(‘scatter plot of Gaussian distributed Random numbers’);
X1=rand(1.5000);
X2=rand(1,5000);
Figure;plot(x1,x2,1.1);
Title(‘scatter plot of uniform distributed random number);
X3=rand(1,00000);
Figure;Subplot(2,1,1);hist(x4);
Title(‘Guassian distribution’);
Ymn=mean(x4);
Yvar=var(x4);
Skew=skewness(x4)
38
SDITW, NANDYAL [Link] ECE
39
SDITW, NANDYAL [Link] ECE
Result:
40
SDITW, NANDYAL [Link] ECE
[Link] a program to plot the impulse response of a Raised cosine
filter.
CLC;clear all;
T=linspace(-30,30,1000);
B=0.2;
Ts=1;
H1=(sin(pi*t/TS)./(pi*t/TS);
H2=(cos(pi*b*t/TS))./(1-(2*b*t/TS).^2);
H=h1*h2;
Figure;plot(t,h);
RESULT:
41
SDITW, NANDYAL [Link] ECE
15. Write a program to verify weiner-khintichine theorem for the following
signal
X(t)=sin(2∏(15t)+sin(2∏(30)t).
CLC;clear all;
FS=100;
T=0;1∕FSL:10;
X=sin(2*pi*15*t)+sin(2*pi*30*t);
N=512;
X=fft(x,N)
F=FS*(0:N-1);
=0:(N-1)FS.
Power=x.*conj(X);
Figure;
Plot(f,energy);
Title(‘energy spectrum through fourier transform’);
Xlabel (‘frequency f’);
Ylabel (‘energy);
Figure:
Rxx=xcorr(x,x);
Sxx=fft(rxx,512);
Plot(f,abs(sxx));
Xlabel(‘frequency f’);
Ylabel(‘abs(sxx)’);
42
SDITW, NANDYAL [Link] ECE
RESULT:
.
43