You are on page 1of 37

Experiment No.

1
Aim:
To represent the basic signal ( Unit impulse , Unit Step , Unit Ramp , Sine and Cosine Signals )

Apparatus:
Computer, MATLAB software

Procedure:
1) 2) 3) 4) Open the computer. Use the MATLAB program. Open the M file from MATLAB. Write the program for unit pulse, unit step, ramp, Exponential, sine wave and cosine wave signals in MATLAB editor. 5) Save and Run the program. 6) Go to command windows. 7) See the result in figure window of MATLAB.

Program:
%plotting the basic signals %unit step x=[0,1,2,3,4]; y=[1,1,1,1,1]; subplot(3,2,1); stem(x,y); xlabel('time') ylabel('amplitude') title('unit step')

%unit impulse x=[-2,-1,0,1,2]; y=[0,0,1,0,0]; subplot(3,2,2); stem(x,y); xlabel('time') ylabel('amplitude') title('unit impulse') %ramp signal n=0:1:5; subplot(3,2,3); stem(n,n); xlabel('time') ylabel('amplitude') title('ramp signal')

%sine function x=0:.01:pi; y=sin(2*pi*x); subplot(3,2,4); stem(x,y); xlabel('time') ylabel('amplitude') title('sine function') %cos function x=0:.01:pi; y=cos(2*pi*x); subplot(3,2,5); stem(x,y); xlabel('time') ylabel('amplitude') title('cos function') %exp function x=-2:.1:2; a=5; y=exp(a*x); subplot(3,2,6); stem(x,y); xlabel('time') ylabel('amplitude') title('exp function')

Output:

Figure: Output Waveform

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
Waveforms of Unit impulse, Unit Step, Unit Ramp, Sine and Cosine Signals have been verified.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 2
Aim:
To test Discrete Convolution in time domain

Apparatus:
Computer, MATLAB software

Algorithm:
1) Get two signals x(p) and h(q) in matrix form 2) The convolved signal is denoted by y(n) 3) y(n) is given by formula y (n) =[x(k)h(n-k)] where n=0 to p+q-1 4) Stop

Procedure:
1) 2) 3) 4) 5) 6) Open the computer. Use the MATLAB program. Open the M file from MATLAB. Write the program for Convolution in MATLAB editor. Save and Run the program. Go to command windows. 7) See the result in figure window of MATLAB.

Program:
x = input ('your 1st input'); subplot(2,2,1) stem(x) xlabel('time') ylabel('amplitude') title('First input') y = input ('your 2nd input'); subplot(2,2,2) stem(y) xlabel('time') ylabel('amplitude') title('Second input') c=conv(x,y) subplot(2,2,3) stem(c) xlabel('time') ylabel('amplitude') title('Output')

Output:
your 1st input [ 1 0 2] your 2nd input [1 3] c=1 3 2 6

Figure: Output Waveform

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The test for discrete convolution for two signals is verified.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 3
Aim:
To test Discrete Cross correlation in time domain

Apparatus:
Computer, MATLAB software

Algorithm:
1. Get two signals x(p) and h(q) in matrix form 2. The convolved signal is denoted by y(n) 3. y(n) is given by formula y (n) =[x(k)h(k-n)] where n=-[max(m, p)-1] to[max(m, p)-1] 4. Stop

Procedure:
1) 2) 3) 4) 5) 6) Open the computer. Use the MATLAB program. Open the M file from MATLAB. Write the program for Correlation in MATLAB editor. Save and Run the program. Go to command windows. 7) See the result in figure window of MATLAB.

Program:
x = input ('your 1st input'); subplot(2,2,1) stem(x) xlabel('time') ylabel('amplitude') title('First input') y = input ('your 2nd input'); subplot(2,2,2) stem(y) xlabel('time') ylabel('amplitude') title('Second input') d = xcorr(x,y) subplot (2,2,3) stem(d) xlabel('time') ylabel('amplitude') title('Output of 1st input') e = xcorr(x,x) subplot (2,2,4) stem(e) xlabel('time') ylabel('amplitude') title('Output of 2nd input')

Output:
your 1st input [ 1 0 2] your 2nd input [1 3] d=0 e=2 3 0 1 5 6 0 2 2

Figure: Output Waveform

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The test for discrete cross correlation for two signals is verified.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 4
Aim:
To test stability using MATLAB

Apparatus:
Computer, MATLAB software

Procedure:
1) 2) 3) 4) 5) 6) 7) Open the computer. Use the MATLAB program. Open the M file from MATLAB. Write the program stability test in MATLAB editor. Save and Run the program. Go to command windows. See the result in command window of MATLAB.

Program:
den=[1 5 2 6] b=poly2rc(den) k=all(abs(b)<1) if k==1 display ('stable system') else display('unstable system') end

Output:
den = 1 5 2 6

b= 0.1111 0.8000 6.0000 k= 0 unstable system >> den = 7 b= 1.0000 -0.4286 0 k= 1 stable system >> 4 -3 0

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
Stability test is verified.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 5
Aim:
Write a program for computing Inverse Z- Transform of a rational transfer Function

Apparatus:
Computer, MATLAB

Algorithm:
1. 2. 3. 4.

Enter the numerator coefficients. Enter the denominator coefficients. Enter the number of points to be computed. Stop.

Procedure:
1. 2. 3. 4.

Open the computer. Use the MATLAB program. Open the M File from MATLAB. Write the program for inverse Z-transform in the MATLAB editor.

Program:
n=[2 3]; d=[1 1.25 0.125 -0.125]; y=impz(n,d) disp('inverse Z.T of the given T.F is ....') disp(y)

Output:
y= 2.0000 0.5000 -0.8750 1.2813 -1.4297 1.5176 -1.5581 1.5792 -1.5896 1.5948 -1.5974 1.5987 -1.5993 1.5997 inverse Z.T of the given T.F is .... 2.0000 0.5000 -0.8750 1.2813 -1.4297 1.5176 -1.5581 1.5792 -1.5896 1.5948 -1.5974 1.5987 -1.5993 1.5997

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The inverse Z-transform of a rational transfer function is computed.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 6
Aim:
Write a program to understand Sampling theorem

Apparatus:
Computer, MATLAB

Algorithm:
1. Sketch the signals x=cos(7t) + cos(23t). 2. Compute and sketch the sampled signals with sampling rate .05,0.1 and 0.2 . 3. Reconstruct the signal to verify sampling theorem .

Procedure:
1. Open the computer. 2. Use the MATLAB program. 3. Open the M File from MATLAB. 4. Write the program for Sampling theorem in the MATLAB editor.

Program:
t=[0:0.005:2]; x=cos(7*t)+cos(23*t); subplot(3,2,1) plot(t,x); grid; xlabel('Time in sec') ylabel('Amplitude'); title('Continuous Signal'); Ts1=0.05; Ts2=0.1; Ts3=0.2; t1=[0:Ts1:2]; xs1=cos(7*t1)+cos(23*t1); subplot(3,2,2); stem(t1,xs1); hold on plot(t,x); hold off grid; xlabel('Time in sec'); ylabel('Amplitude'); title('Sampled signal with Ts =.05sec'); t2=[0:Ts2:2]; xs2=cos(7*t2)+cos(23*t2); subplot(3,2,3); stem(t2,xs2); hold on plot(t,x); hold off grid; xlabel('Time in sec'); ylabel('Amplitude'); title('Sampled signal with Ts =.1sec'); t3=[0:Ts3:2]; xs3=cos(7*t3)+cos(23*t3); subplot(3,2,4); stem(t3,xs3); hold on
1

plot(t,x); hold off grid; xlabel('Time in sec'); ylabel('Amplitude'); title('Sampled signal with Ts =.2sec'); %output when sampling period T=0.05 sec subplot(3,2,5); plot(t1,xs1); title('Output with Ts =.05sec'); %output when sampling period T=0.2 sec. This results in Aliasing subplot(3,2,6); plot(t3,xs3); title('Aliased output with Ts =.2sec');

Output:

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The Sampling theorem is verified.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 7
Aim:
Write a program to convert an analog filter in to digital filter using Bilinear Transformation.

Apparatus:
Computer, MATLAB

Procedure:
1. Open the computer. 2. Use the MATLAB program. 3. Open the M File from MATLAB. 4. Write the program for conversion.

Program:
clc,clear all;close all; b=[2]; a=[1 4 3]; fs=10; disp('Transfer Function H(s) in analog domain') Hs= tf(b,a) [bz,az]=bilinear(b,a,fs); disp('Transfer Function H(z) in digital domain ') Hz= tf(bz,az)

Output:
Transfer Function H(s) in analog domain Transfer function: 2 ------------s^2 + 4 s + 3 Transfer Function H(z) in digital domain Transfer function: 0.004141 s^2 + 0.008282 s + 0.004141 -----------------------------------s^2 - 1.644 s + 0.6687

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The analog filter is converted into digital filter.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 8
Aim:
Write a program to convert an analog filter in to digital filter using Impulse Invariant Method.

Apparatus:
Computer, MATLAB

Algorithm:
1. 2. 3. 4. Enter the numerator coefficients. Enter the denominator coefficients. Enter the number of points to be computed. Stop.

Procedure:
1. Open the computer. 2. Use the MATLAB program. 3. Open the M File from MATLAB. 4. Write the program for inverse Z-transform in the MATLAB editor.

Program:
clc,clear all;close all; b=[1]; a=[1 3 2]; fs=1; disp('Transfer Function H(s) in analog domain') Hs= tf(b,a) [bz,az]=impinvar(b,a,fs); disp('Transfer Function H(z) in digital domain ') Hz= tf(bz,az)

Output:
Transfer Function H(s) in analog domain Transfer function: 1 ------------s^2 + 3 s + 2 Transfer Function H(z) in digital domain Transfer function: 0.2325 -----------------------s^2 - 0.5032 s + 0.04979

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The analog filter is converted into digital filter.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 9
Aim:
Write a program for the design of digital filter a) Low Pass Filter b) High Pass Filter c) Band Pass Filter d) Band Stop Filter For FIR rectangular window

Apparatus:
Computer, MATLAB

Procedure:
1. Open the computer. 2. Use the MATLAB program. 3. Open the M File from MATLAB. 4. Write the program for Low pass, High pass, Band pass and Band stop in MATLAB Editor. 5. Save and Run the program. 6. Go to command window. 7. Use the ; to terminate the program. 8. See the result in Figure Window of MATLAB.

Program:
% low pass filter fs = 500; [b,a] = fir1(8 , 10/(fs/2) , 'low' , rectwin(9)); [h,o] = freqz(b,a,256); m = 20*log10(abs(h)); subplot(2,2,1) plot (o/pi,m) xlabel('Frequency') ylabel('Amplitude') title('Low Pass ') % high pass filter fs = 500; [b,a] = fir1(8 , 10/(fs/2) , 'high' , rectwin(9)); [h,o] = freqz(b,a,256); m = 20*log10(abs(h)); subplot(2,2,2) plot (o/pi,m) xlabel('Frequency') ylabel('Amplitude') title('High Pass') % band pass filter fs = 500; [b,a] = fir1(8 , [70/(fs/2),80/(fs/2)] , 'bandpass' , rectwin(9)); [h,o] = freqz(b,a,256); m = 20*log10(abs(h)); subplot(2,2,3) plot (o/pi,m) xlabel('Frequency') ylabel('Amplitude') title('Band Pass ')

% band stop filter fs = 500; [b,a] = fir1(8 , [70/(fs/2),80/(fs/2)] , 'stop' , rectwin(9)); [h,o] = freqz(b,a,256); m = 20*log10(abs(h)); subplot(2,2,4) plot (o/pi,m) xlabel('Frequency') ylabel('Amplitude') title('Band Stop')

Output:

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The digital filters are designed.

Remarks: _______________ T.Signature: _____________ Date:___________________

Experiment No. 10
Aim:
Write a program to analyze the effect of noise on the desired signal and to recover it back using FIR filters.

Apparatus:
Computer, MATLAB

Algorithm:
1. 2. 3. 4. 5. 6. Generate a Desired Signal. Generate Noisy Random Signal. Add noise to the generated signal. Create FIR low pass filter. Filter out noise from the noisy signal. Stop.

Procedure:
1. Open the computer. 2. Use the MATLAB program. 3. Open the M File from MATLAB. 4. Write the program for generation of desired signal, Noisy Signal and Create FIR low pass filter in MATLAB Editor. 5. Save and Run the program. 6. Go to command window. 7. See the result in Figure Window of MATLAB.

Program:
fs=600 t= 0:0.001:0.5; x=cos(2*pi*t*25) subplot(4,1,1) plot(x); title('Cosine Signal') % To Generate Noise y=randn(size(t)) subplot(4,1,2) plot(y) title('Random Noise Signal') % To Generate Noisy Cosine Signal z=x+y subplot(4,1,3) plot(z) title('Noisy Cosine Signal') % Filter Noisy Signal [b,a]= fir1(8,10/(fs/2),'low') w = filtfilt(b,a,z) subplot(4,1,4) plot(w) title('Filtered Noisy Signal')

Output:

Precautions:
1) Log in and log out should be done properly. 2) While working if any problem is faced contact lab tech/faculty.

Result:
The effect of noise on the desired signal is studied and is filtered using FIR Filters.

Remarks: _______________ T.Signature: _____________ Date:___________________