Satyam Singh (SNS Lab File)
Satyam Singh (SNS Lab File)
– 1
Result:
Plotting of unit step, unit impulse, ramp ,
exponential functions and sinusoidal signals using
MATLAB software is completed.
Experiment No. – 3
Result:
Study of convolution of two functions using MATLAB is
finished successfully.
Experiment No. – 4
Program:
clear all ;
close all ;
clc;
%definition of x
x=[1 2 3 4];
subplot(4,1,1);
stem(x);
xlabel('time');
ylabel('amplitude');
title('Definition of x');
%definition of h
h=[4 3 2 1];
subplot(4,1,2);
stem(h);
title('Definition of h');
xlabel('time');
ylabel('amplitude');
%autocorrelation of x&x
y=xcorr(x,x);
subplot(4,1,3);
stem(y);
title('Autocorrelation');
xlabel('time');
ylabel('amplitude');
%crosscorrelation of x&h
y=xcorr(x,h);
subplot(4,1,4);
stem(y);
title('Crosscorrelation');
xlabel('time');
ylabel('amplitude');
Output:
Result:
Study of auto correlation and cross correlation of two
sequences using MATLAB is finished successfully.
Experiment No. – 5
Aim: To plot the magnitude and phase plot spectrum
of signal using Fourier Series .
Theory:
𝑇
Cn = 1/T ∫0 𝑥 (𝑡)𝑒 −𝑗𝑛𝑤𝑡 dt
The function abs (|Cn|) returns the magnitude and angle (<Cn) returns
the phase angle in radians.
Magnitude Response is |Cn| vs. n and phase plot is <Cn vs. n.
Program:
clc;
clear all;
close all;
syms t;
T = pi;
w = 2*pi/T;
xt = exp(-t/2);
n = -6:6;
Cn = 1/T*int(xt*exp(-1j*w*n*t),t,0,T);
Cn = double(Cn
%magnitude
magnitudeCn = abs(Cn)
%angle
angleCn = angle(Cn)
subplot(2,1,1);
stem(n,magnitudeCn);
grid on
xlabel('n');
ylabel('|Cn|');
title('Magnitude Plot');
subplot(2,1,2);
stem(n,angleCn);
grid on
xlabel('n');
ylabel'<Cn');
title('Phase Plot');
Output:
Theory:
A function derived from a given function and representing it by a
series of sinusoidal functions. The Fourier Transform decomposes any
function into a sum of sinusoidal basis functions. Each of these basis
functions is a complex exponential of a different frequency.
The following definition:
∞
F(s) = ∫−∞ 𝑓(𝑥)𝑒 −2ð𝑗𝑥𝑠 𝑑𝑥
for any real number .
Program :
clc;
clear all;
close all;
syms t omega;
xt = 2;
expw = exp (-j*omega*t) ;
xjw = int (xt*expw,omega,-2,2) ;
xjw = simplify (xjw) ;
figure (1) ;
subplot (2,1,1) ;
ezplot ('2',[-2 2]) ;
grid on
subplot (2,1,2) ;
ezplot(xjw); grid on
Output:
clc;
clear all;
close all;
n1=-2:2;
xn1=ones(1,5);
%rectangular function
k=-400:400; w=(pi/100)*k;
Xw=xn1*(exp(-
1*j*pi/100).^(n1'*k));
magXw1=abs(Xw);
subplot(2,2,1);
stem(-8:8,[zeros(1,6) xn1
zeros(1,6)]);
xlabel('n');
ylabel('x');
title('rectangular signal');
subplot(2,2,3);
plot(w/pi,magXw1);
xlabel('frequency in pi units');
ylabel('magnitude');
title('DTFT');
n2=0:100;
xn2=cos(pi*n2/4);
%sinusoidal signal
Xw2=xn2*(exp(-
1*j*pi/100).^(n2'*k));
magXw2=abs(Xw2);
subplot(2,2,2);
stem(n2,xn2);
axis([0 100 -1.5 1.5]);
xlabel('n');
ylabel('xn');
title('sinusoidal signal');
subplot(2,2,4);
plot(w/pi,magXw2);
xlabel('frequency in pi units');
ylabel('magnitude');
title('DTFT');
Output:
Program:
%sampling
theorem
clc; close all;
clear all;
t=0:0.01:1;
fm=input('enter frequency
fm');
xt=cos(2*pi*fm*t);
subplot(411); plot(t,xt);
title('cos function');
xlabel('time--->');
ylabel('amplitude--->');
%program sampling at
(A)(fs<2fm)
fs1=1.3*fm;
n1=0:1/fs1:1;
xn1=cos(2*pi*fm*n1);
subplot(412);
plot(t,xt,'r',n1,xn1,'b');
title('undersmapling');
xlabel('time--->.');
ylabel('amplitude--->');
%program sampling at
(B)(fs=2fm)
fs2=2*fm;
n2=0:1/fs2:1;
xn2=cos(2*pi*fm*n2);
subplot(413);
plot(t,xt,'r',n2,xn2,'b');0
title('nyquist rate');
xlabel('time--->');
ylabel('amplitude--->');
%program sampling
at(C)fs<2fm
fs3=2.9*fm;
n3=0:1/fs3:1;
xn3=cos(2*pi*fm*n3);
subplot(414);
plot(t,xt,'r',n3,xn3,'b');
title('oversampling');
xlabel('time--->');
ylabel('amplitude--->');
Output: