BSLAB Basic Simulation Lab

54
BASIC SIMULATION LAB OBSERVATION YEAR/SEMESTER DEPARTMENT OF ECE IND

description

well

Transcript of BSLAB Basic Simulation Lab

Page 1: BSLAB Basic Simulation Lab

BASIC SIMULATION LAB OBSERVATION

YEAR/SEMESTER

DEPARTMENT OF ECE

IND

Page 2: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

INDEX

Experiment

No.Name of the Experiment

Page No.

Signature of Lab Incharge

01 Basic operations on Matrices 2

02Generation Of Various Signals and Sequence ( periodic and aperiodic)

7

03 Operations on signals and sequence 10

04 Even and Odd parts of signal and sequence 13

05Convolution Between Signals and Sequences

15

06 17

07Auto correlation and Cross correlation between signals and sequences

19

08Computation of Unit sample, Unit step and sinusoidal response of LTI system

23

09Reconstruction of Periodic Signal by its Fourier Series

27

10Locating Zeros and Poles on S-Plane and Z-Plane

29

11 Sampling Theorem 33

12Removal of noise by Auto correlation / Cross Correlation

44

13 Impulse response of a raised cosine filter 48

PMS_PSKR: 1

Page 3: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 01 Date:

Basic operations on Matrices

Mathematical FunctionsMATLAB contains a set of built-in mathematical functions.

All of these functions are applied to arrays on an element by element basis. Thus, they return an array having the same size as the input array with elements all modified in the same way. We have already defined and used five of the functions. These are

sqrt - square rootreal - complex number real partimag - complex number imaginary partabs - complex number magnitudeangle - complex number angleIf a number is real, then abs produces the absolute value of the number. Other available mathematical functions that are of interest to us in signal and system analysis includeexp - exponential base elog - logarithm base elog 10 - logarithm base 10sin - sinecos - cosinetan - tangentasin - arcsineacos - arccosineatan - arctangentatan2 - four quadrant arctangentround - round to nearest integer[The trigonometric functions all apply to angles expressed in radians.]

Mathematical ExpressionsWe can combine arithmetic operations, 0-1 arrays generated by logical operations, and mathematical functions into mathematical expressions. Often, these expressions take the form of equations, although they may also be used in flow control statements. Thearithmetic operations follow the usual precedence rules. Many mathematical expressions require parentheses to construct the desired sequence of operations within the precedence rules.>> t=0.1; x=2^t*sqrt(t) - sin(2*t)/3x = 0.2727

PMS_PSKR: 2

Page 4: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

>> y=2^(t*sqrt(t)) - sin(2*t)/3y = 0.9559We can evaluate a mathematical expression for a set of independent variable values by expressing the independent variable as a one-dimensional array (vector) and using array operations.>> f=0:2:4; w=2*pi*f;>> X=(3 - j*0.1*w)./(1.5+j*0.2*w)X = 2.0000 0.1566 - 1.1002i -0.2956 - 0. 6850iOne important use of a 0-1 array for signal and system analysis is in the representation of a piecewise defined signal with a mathematical expression.>> t=-0.5:0.5:2.5;>> x=(t+1).*(t>=0&t<1)+2*(t>=1&t<=2)x = 0 1.0000 1.5000 2.0000 2.0000 2.0000 0The notation .* is required for the first mulitplication since we want element by elementmultiplication of the two like-sized, one-dimensional arrays. We can use just * for thesecond multiplication since it is a constant times an array.

PMS_PSKR: 3

Page 5: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 02 Date:

Generation Of Various Signals and Sequence( periodic and aperiodic)

AIM: To write a MATLAB program to generate the standard discrete time signals like unit impulse, unit step, unit ramp signals, discrete time signals, sinusoidal signals and exponential signals.

Program To Plot Standard Signals:

%Create a time base vector

t = [0:0.1:2];% Create a signal as a function of time

x = sin(pi*t/2);

subplot(3,3,1);

plot(t,x);

%Nonperiodic Signals

t = linspace(0,1,11);

%Step:

y = ones(1,11);

subplot(3,3,2);

stem(y);

axis([-1 6 0 2]);

% Impulse:

y = [1 zeros(1,10)];

subplot(3,3,3);

stem(y);

axis([-1 6 0 2]);

% Ramp:

PMS_PSKR: 4

Page 6: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

y = 2*t;

subplot(3,3,4);

plot(y);

axis([-1 6 0 2])

%Useful Matlab functions step, impulse, gen signal

%Step function:

fs = 10;

ts = [0:1/fs:5 5:1/fs:10];

x = [zeros(1,51) ones(1,51)];

subplot(3,3,5);

stairs(ts,x);

%Impulse function with width w:fs = 10;

w = 0.1;

ts = [-1:1/fs:-w 0 w:1/fs:1];

x = [zeros(1,10) 1 zeros(1,10)];

subplot(3,3,6);

plot(ts,x);

%Sinusoids

%Sinusoid parameters

%Amplitude, A

%Frequency, f

%Phase shift,

%Vertical offset, B

%The general form of a sine wave is

%y = Asin(2 ft + ) + B

PMS_PSKR: 5

Page 7: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

%Example: generate a sine wave given the following speculations:

%A = 5

%f = 2 Hz

%PS=π/8 radians

t = linspace(0,1,1001);

A = 5;

f = 2;

PS = pi/8;

sinewave = A*sin(2*pi*f*t + PS);

subplot(3,3,7);

plot(t, sinewave);

%Square Waves

%Square wave generation is like sine wave generation, but you specify a duty cycle, which is the percentage of the time over one period that the amplitude is high.

%Example:

% duty cycle is 75%

%frequency is 4 Hz.

t = linspace(0,1,1001);

sqw2 = square(2*pi*4*t,75);

subplot(3,3,8);

plot(t,sqw2);

axis([-0.1 1.1 -1.1 1.1]);

%Sawtooth Waves

%Sawtooth waves are like square waves except that instead of specifying a duty cycle, you specify the location of the peak of the sawtooth.

%Example:

PMS_PSKR: 6

Page 8: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

%peak is halfway through the period

%frequency is 3 Hz.

t = linspace(0,1,1001);

saw2 = sawtooth(2*pi*3*t,1/2);

subplot(3,3,9);

plot(t,saw2);

RESULT

Figure :Periodic and aperiodic signals

Questions:1. Define the different signals like step, ramp, impulse,

sinusoidal and exponential.2. What is the difference between analog signals and digital

signals?3. Express the ramp signal in terms of step. 4. Draw the different signal waveforms.

PMS_PSKR: 7

Page 9: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 03 Date:

Operations on signals and sequence

AIM: To perform various operations on signals and sequence such as addition, multiplication, scaling, shifting and folding computation of energy and average power using MATLAB Code.

Program demonstrating Basic Signal Manipulation:

N=128;

f1=150;

f2=450;

f3=1500;

fs=8000;

n=0:N-1;

x1=sin(2*pi*(f1/fs)*n);

x2=(1/3)*sin(2*pi*(f2/fs)*n);

x3=sin(2*pi*(f3/fs)*n);

figure(1);

subplot(1,1,1);

subplot(2,3,1);

plot(n,x1);

grid;

title('Signal, x1(n)');

subplot(2,3,2);

plot(n,x2);

grid;

title('Signal, x2(n)');

subplot(2,3,3);

plot(n,x3);

grid;

title('Signal, x3(n)');

PMS_PSKR: 8

Page 10: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

% Signal Delay

x1d=[zeros(1,20), x1(1:N-20)];

subplot(2,3,4);

plot(n,x1d);

grid;

title('Delayed x(n), [x1(n-20)]');

% Signal Addition

xadd=x1+x2;

subplot(2,3,5);

plot(n,xadd);

grid;

title('x1(n)+x2(n)');

% Signal Multiplication

xmult=x1.*x3;

subplot(2,3,6);

plot(xmult);

grid;

title('x1*x3');

PMS_PSKR: 9

Page 11: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULTS:

Figure : Basic signal Manipulation with respect to time

Questions:1. What are the various mathematical operations on signals?2. Define the various mathematical operations like addition,

multiplication, division and average with respect to signals.3. Define scaling of a signal.4. What is the difference between frequency scaling and

amplitude scaling?

PMS_PSKR: 10

Page 12: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No:04 Date:

Even and Odd parts of signal or sequence

AIM: To write a MATLAB code for finding the a) Even and Odd parts of signal or sequence b) Real and imaginary parts of signal.

% Finding the even and odd part of the signal x(n)=0.8^n

n=-5: 1: 5; %specify the range of n

A=0.8;

x1=A.^(n); %generate the given signal

x2=A.^(-n); %generate the folded signal

if(x2==x1)

disp('The given signal is even signal');

else if (x2==(-x1))

disp('The given signal is odd signal');

else

disp('The given signal is neither even nor odd signal');

end

end

xe=(x1+x2)/2; %compute even part

xo=(x1-x2)/2; %compute odd part

subplot(2,2,1);stem(n,x1);

xlabel('n');ylabel('x1(n)');title('signal x(n)');

subplot(2,2,2);stem(n,x2);

xlabel('n');ylabel('x2(n)');title('signal x(-n)');

subplot(2,2,3);stem(n,xe);

xlabel('n');ylabel('xe(n)');title('even part of x(n)');

subplot(2,2,4);stem(n,xo);

xlabel('n');ylabel('xo(n)');title('odd part of x(n)');

PMS_PSKR: 11

Page 13: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure : Even and odd parts of given signal

PMS_PSKR: 12

Page 14: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

B) Finding Real and imaginary parts of signal.

t = [-0.5:0.01:0.5];w=20;y = exp(i*pi*w*t/2);

a=real(y);subplot(2,2,1);plot(t,a);b=imag(y);subplot(2,2,2);plot(t,b);c=abs(y);subplot(2,2,3);plot(t,c);d=angle(y);subplot(2,2,4);plot(t,d);

Figure: Real and imaginary parts of signal

Questions:1. Define the Even and Odd Signals.2. Give the expressions for the Even and Odd signals.3. What is the real and imaginary part of the signal?

PMS_PSKR: 13

Page 15: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 05a Date:Convolution Between Signals

AIM: To write a MATLAB program to perform convolution of the following two signals.

X1(t) =1; 0<t<2

x2(t) =1; 0<t<1

=-1; 1<t<2

Program:

tmin=0; tmax=4; dt=0.01;

t=tmin:dt:tmax; %set time vector for given signal

x1=1.*(t>=0&t<=2); %generate signal x1(t)

xa=1;

xb=-1;

x2=xa.*(t>=0&t<=1)+ xb.*(t>=1&t<=2);

% generate signal x2(t)

x3=conv(x1,x2); % perform convolution of xl(t) & x2(t)

n3=length(x3);

t1=0:1:n3-1; %set time vector for signal x3(t)

subplot(3,1,1);plot(t,x1);

xlabel(‘t’);ylabel(‘x1(t)’);title(‘signal x1(t)’);

subplot(3,1,2);plot(t,x2);

xlabel(‘t’);ylabel(‘x2(t)’);title(‘signal x2(t)’);

subplot(3,1,3);plot(t1,x3);

xlabel(‘t/dt’);ylabel(‘x3(t)/dt’);title(‘signal, x3(t)=x1(t)*x2(t)’);

PMS_PSKR: 14

Page 16: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULTS:

Figure :Convolution between CT signals

PMS_PSKR: 15

Page 17: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

B)Convolution Between Sequences

AIM: To write a MATLAB program to perform convolution of the following two discrete time signals.

x1(n)=1; 1<n<10

x2(n)=1; 2<n<10

Program to perform convolution of two signals:

clear all

n=0:1:15; %specify range of n

x1=1.*(n>=1 & n<=10) ; %generate signal x1(n)

x2=1.*(n>=2 & n<=10); % generate signal x2(n)

N1=length(x1);

N2=length(x2);

x3=conv(x1,x2); % convolution of signals x1(n)and x2(n)

n1=0: 1: N1+N2-2; %specify range of n for x3(n)

subplot(3,1,1);stem(n,x1);

xlabel('n');ylabel('x1(n)');

title('signal x1(n)');

subplot(3,1,2);stem(n,x2);

xlabel('n');ylabel('x2(n)');

title('signal x2(n)');

subplot(3,1,3);stem(n1,x3);

xlabel('n');ylabel('x3(n)');

title('signal , x3(n)=x1(n)*x2(n)');

PMS_PSKR: 16

Page 18: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure :Convolution between DT signals

Questions:

1. Define convolution.

2. What is the difference between sequence and signal?

PMS_PSKR: 17

Page 19: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 07 Date:

Auto correlation and Cross correlation between signals and sequences

AIM: To find Auto correlation and Cross correlation between signals and sequences using MATLAB Code.

Program for auto correlation:

N=1024; % Number of samples

f1=1; % Frequency of the sine wave

FS=200; % Sampling Frequency

n=0:N-1; % Sample index numbers

x=sin(2*pi*f1*n/FS); % Generate the signal, x(n)

t=[1:N]*(1/FS); % Prepare a time axis

subplot(2,1,1); % Prepare the figure

plot(t,x); % Plot x(n)

title('Sinwave of frequency 1000Hz [FS=8000Hz]');

xlabel('Time, [s]');

ylabel('Amplitude');

grid;

Rxx=xcorr(x); % Estimate its autocorrelation

subplot(2,1,2); % Prepare the figure

plot(Rxx); % Plot the autocorrelation

grid;

title('Autocorrelation function of the sinewave');

xlable('lags');

ylabel('Autocorrelation');

PMS_PSKR: 18

Page 20: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure :Auto correlation function of the Sine wave

PMS_PSKR: 19

Page 21: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Program for cross correlation:

N=1024; % Number of samples to generate

f=1; % Frequency of the sinewave

FS=200; % Sampling frequency

n=0:N-1; % Sampling index

x=sin(2*pi*f1*n/FS); % Generate x(n)

y=x+10*randn(1,N); % Generate y(n)

subplot(3,1,1);

plot(x);

title(‘Pure Sinewave’);

grid;

subplot(3,1,2);plot(y);

title(‘y(n), Pure Sinewave + Noise’);

grid;

Rxy=xcorr(x,y); % Estimate the cross correlation

subplot(3,1,3);

plot(Rxy);

title(‘Cross correlation Rxy’);

grid;

PMS_PSKR: 20

Page 22: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure : Cross correlation function of sine wave and Noise

Questions:

1. Define auto correlation.2. Define cross correlation.3. What is the difference between auto and cross

correlations?

PMS_PSKR: 21

Page 23: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 08 Date:Computation of Unit sample, Unit step and

sinusoidal response of LTI system

AIM: Write a MATLAB program to compute and sketch the impulse response of a discrete time system governed by the following transfer function,

H(Z)=1/(1-0.8Z^-1+0.16 Z^-2)

Program to find 'impulse response of a discrete time System:

clear all

syms z n

H=1/(1-0.8*(z^(-1))+0.16*(z^(-2)));

disp('impulse response h(n) is');

h=iztrans(H) ; %compute impulse response

simplify(h)

N=15;

b=[0 0 1]; %numerator coefficients

a=[1 -0.8 0.16]; %denominator coefficients

[H,n]=impz(b,a,N); %compute N samples of impulse response

Stem(n,H); %sketch impulse response

xlabel('n');

ylabel('h(n)');

title('impulse response of a DT System');

PMS_PSKR: 22

Page 24: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure:Impulse Response of a DT system

PMS_PSKR: 23

Page 25: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

AIM: To write a MATLAB program to find the step response of the first and second order LTI systems governed by the following transfer functions,

H(s)=1/(s+2) and H(s)=1/(s2+2.5s+25) .

Program to find the step response of I and II order systems:

syms s complex;

H1=1/(s+2);

disp('step response of first order system is');

h1= ilaplace(H1);

simplify(h1)

H2=1/(s^2+2.5*s+25);

disp('step response of second order system is');

h2= ilaplace(H2);

simplify(h2)

s=tf('s');

H1=1/(s+2);

H2=1/(s^2+2.5*s+25);

t1=0: 0.0005 :5; %set a time vector

s1=step(H1,t1); % step response of first order system

s2=step(H2,t1); % step response of second order system

subplot(2,1,1);plot(t1,s1);

xlabel('Time in seconds');ylabel('s1(t)');

title('step response of first order system');

subplot(2,1,2);plot(t1,s2);

xlabel('Time in seconds');

ylabel('s2(t)');

title('step response of second order system');

PMS_PSKR: 24

Page 26: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure : Unit Step Response for given I and II order systems

Questions:

1. Define impulse signal and step signal.

2. What is impulse response and step response?

3. What are the time response specifications?

PMS_PSKR: 25

Page 27: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 09 Date:

Reconstruction of Periodic Signal by its Fourier Series

AIM: Write a MATLAB program to reconstruct the following periodic signal represented by its fourier series , by considering only 3,5 and 59 terms.

x(t)=(1/2)+ bn sinnΩ0 . where bn=2/n; Ω0=2nF; F=1

Program:

syms t real;

N=input('Enter number of signals to reconstruct');

n_har=input('enter number of harmonics in each signal as array');

t=-1: 0.002:1;

omega_o=2*pi;

for k=1:N

n=[ ];

n=[1:2:n_har(k)];

b_n=2./(pi*n);

L_n=length(n);

x=0.5+b_n*sin(omega_o*n'*t);

subplot(N,1,k);

plot(t,x);

xlabel('t');

ylabel('recons signal');

axis( [-1 1 -0.5 1.5]);

text(.55, 1.0,['no.of har.=',num2str(n_har(k))]);

end

PMS_PSKR: 26

Page 28: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Enter number of signals to reconstruct : 3

enter number of harmonics in each signal as array[3 5 59]

.

Figure : Gibbs phenomenon

Questions:

1. What is fourier series?

2. Define periodic and non periodic signals.

3. What is the difference between FS and DFS?

PMS_PSKR: 27

Page 29: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 10 Date:

Locating Zeros and Poles on S-Plane and Z-Plane

AIM: To write a MATLAB program for finding residues and poles of s-domain transfer function

Program:

clc;close all;clear all;disp('Enter the transfer function of the original system');N=input('Enter the co efficients of the numarator:');D=input('Enter the co efficients of the denominator:');disp('The transfer function of the original system:');G=tf(N,D);ltiview(G);

PMS_PSKR: 28

Page 30: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Enter the transfer function of the original system

Enter the co efficients of the numarator: [1 2 3]

Enter the co efficients of the denominator: [2 3 3]

The transfer function of the original system:

Figure : Pole-zero map for s-domain transfer function

PMS_PSKR: 29

Page 31: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

AIM: To write a MATLAB program for finding residues and poles of z-domain signal is given below

(Z^2+0.8Z+0.8)/(Z^2+0.49),

And sketch the pole zero plot.

Program

clear allsyms znum_coeff=[1 0.8 0.8];disp('Roots of numerator polynomial Z^2+0.8Z+0.8 are');zeros=roots(num_coeff)

den_coeff=[1 0 0.49];disp('Roots of denominator polynomial Z^2+0.49 are');poles=roots(den_coeff)H=tf('z');Ts=0.1;

a=tf([num_coeff], [den_coeff], Ts);zgrid on;pzmap(a); %pole -zero plotRoots of numerator polynomial Z^2+0.8Z+0.8 are

zeros =

-0.4000 + 0.8000i -0.4000 - 0.8000i

Roots of denominator polynomial Z^2+0.49 are

poles =

0 + 0.7000i 0 - 0.7000i

PMS_PSKR: 30

Page 32: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

RESULT:

Figure : Pole- Zero map for Z-domain signal

Questions:1. Define sampling theorem in both frequency and time domain.2. What is the sampling rate?3. What is the multiple sampling rate?4. What is the Nyquist Sampling Rate?

PMS_PSKR: 31

Page 33: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 12 Date:

Removal of noise by Auto correlation / Cross Correlation

AIM: Removal of noise by Auto / Cross Correlation in a given signal corrupted by noise by using MATLAB Code.

Program

% AutoCorrelation of White Noise

% Loops are used in this program for easier portability to

% C or assembly code.

%

%************************************************************

% N = Length of Time Domain Signal

N = 512;

%************************************************************

% Create an index matrix for graphing:

%************************************************************

for n = 1: 1: N;

index(n) = n;

end

%************************************************************

% Create an expanded index matrix from -N to N for graphing:

%************************************************************

index_expanded = 1:(2*N - 1);

for n = 1: 1: (N - 1);

index_expanded(n) = -(index(N - n));

end

index_expanded(N) = 0;

PMS_PSKR: 32

Page 34: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

for n = (N + 1): 1: (2*N - 1);

index_expanded(n) = index(n - N);

end

%************************************************************

% Generate the flat +- 0.1 white noise:

%************************************************************

w_2 = 1:N;

w_2 = 0.1*rand(1,N);

w_2 = w_2 - mean(w_2);

%************************************************************

% Compute 0.1 white noise Autocorrelation:

%************************************************************

r_xx_w_2 = 1:N;

for m = 1: 1: N;

F = 0;

for k = 1: 1: (N+1-m);

F = F + w_2(k)*w_2(k-1+m);

end

r_xx_w_2(m) = F/(N+1-m);

end

%************************************************************

% Create an expanded 0.1 white noise Autocorrelation Function

% from -N to N for graphing purposes:

%************************************************************

r_xx_w__expanded = 1:(2*N - 1);

for m = 1: 1: N;

r_xx_w_2_expanded(m) = r_xx_w_2(N - m + 1);

end

PMS_PSKR: 33

Page 35: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

for m = N: 1: (2*N - 1);

r_xx_w_2_expanded(m) = r_xx_w_2(m + 1 - N);

end

%************************************************************

% Plot the Results

%************************************************************

figure

plot(index_expanded,r_xx_w_2_expanded)

title(['Auto Correlation Function of 0.1 w.n Input'])

RESULT:

Figure : Auto Correlation function of 0.1 White noise input

Questions:1. Define noise.2. How the signals are affected by the noise?3. What are the differences between random noise and white

noise?

PMS_PSKR: 34

Page 36: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

Expt No: 13 Date:Impulse response of a raised cosine filter

AIM: write a MATLAB code to find the Impulse Response of a Raised Cosine Filter.

Program:

% Script for plotting the time domain and frequency domain representation% of raised cosine filters for various values of alphaclear allfs = 10;% defining the sinc filtersincNum = sin(pi*[-fs:1/fs:fs]); % numerator of the sinc functionsincDen = (pi*[-fs:1/fs:fs]); % denominator of the sinc functionsincDenZero = find(abs(sincDen) < 10^-10);sincOp = sincNum./sincDen;sincOp(sincDenZero) = 1; % sin(pix/(pix) =1 for x =0

alpha = 0;cosNum = cos(alpha*pi*[-fs:1/fs:fs]);cosDen = (1-(2*alpha*[-fs:1/fs:fs]).^2);cosDenZero = find(abs(cosDen)<10^-10);cosOp = cosNum./cosDen;cosOp(cosDenZero) = pi/4;gt_alpha0 = sincOp.*cosOp;GF_alpha0 = fft(gt_alpha0,1024);

close allfigureplot([-fs:1/fs:fs],[gt_alpha0],'b','LineWidth',2)

grid onxlabel('time, t')ylabel('amplitude, g(t)')title('Time domain waveform of raised cosine pulse shaping filters')

figureplot([-512:511]/1024*fs, abs(fftshift(GF_alpha0)),'b','LineWidth',2);axis([-2 2 0 14])grid onxlabel('frequency, f')ylabel('amplitude, |G(f)|')title('Frequency domain representation of raised cosine pulse shaping filters')

PMS_PSKR: 35

Page 37: BSLAB Basic Simulation Lab

Department of Electronics and Communication EngineeringBasic Simulation Lab

PMS_PSKR: 36