Experiment No. - 1: Aim: Software Used: MATLAB Theory
Experiment No. - 1: Aim: Software Used: MATLAB Theory
– 1
Result:
The study of MATLAB and the various commands is
complete.
Experiment No. – 2
Aim: To plot unit step, unit impulse, ramp,exponential
functions & sinusoidal signals.
Software Used: MATLAB
Program:
%Generation of sine wave
t=1:0.01:5;
x=sin(2*pi*t);
subplot(3,2,1);
plot(t,x);
title('sine wave continuous');
xlabel('time');
ylabel('amplitude');
Result:
Plotting of unit step, unit impulse, ramp, exponential
functions and sinusoidal signals using MATLAB software
is completed.
Experiment No. – 3
Aim: To plot Convolution of two functions.
Software Used: MATLAB
Theory:
Convolution of two functions mathematically is given
by: -
f(t)=x(t)*h(t)= ∫𝑥(𝜏)ℎ(𝑡−𝜏)𝑑𝜏∞−∞
Program:
%Definition of i/p sequence
x=input('Enter the value of x');
nx=0:1;
subplot(3,1,1);
stem(nx,x);
grid on;
title('Input Sequence');
xlabel('Time');
ylabel('Amplitude');
%Definition of impulse sequence h
h=input('Enter the value of h');
nh=0:2;
subplot(3,1,2);
stem(nh,h);
grid on;
title('Input impulse seq.');
xlabel('Time');
ylabel('Amplitude');
%Convolution of x & h
nyl=nx(1)+nh(1);
nyr=nx(length(x))+nh(length(h));
ny=nyl:nyr;
y=conv(x,h);
subplot(3,1,3);
stem(ny,y);
grid on;
title('output Sequence');
xlabel('Time');
ylabel('Amplitude');
Outputs:-
Result:
Study of convolution of two functions using MATLAB is
finished successfully.
Experiment No. – 4
Aim: To plot auto correlation and cross correlation of two
sequences..
Result:
Study of auto correlation and cross correlation of two
sequences using MATLAB is finished successfully.
Experiment No. – 5
Aim: Find out the Z transform of a signal.
Software Used: MATLAB
Theory:-
The Z-transform can be defined as either a one-sided or two-sided transform.
Bilateral Z-transform
The bilateral or two-sided Z-transform of a discrete-time signal x[n] is the formal power series X(z)
defined as
Program:
clc;
clear all;
n=0:.1:100;
r=input('enter the r :');
w=pi/4;
y1=r.^(-n);
y2=cos(w*n);
y=y1.*y2;
if (r <1)
subplot(3,1,1);
plot(n,y1);
xlabel('Sample No');
ylabel('amplitude');
title('r^-^n when r<1');
elseif(r==1)
subplot(3,1,1);
plot(n,y1);
xlabel('Sample No');
ylabel('amplitude');
title('r^-^n when r=1');
else
subplot(3,1,1);
plot(n,y1);
xlabel('Sample No');
ylabel('amplitude');
title('r^-^n when r>1');
end
subplot(3,1,2);
plot(n,y2);
xlabel('Sample No');
ylabel('amplitude');
title('cos(wt) when w=pi/4');
subplot(3,1,3);
plot (n,y);
xlabel(' ');
ylabel('amplitude');
title('Real part of z^-^n=r^-^n *cos(wn)');
Output:-
CASE 1: enter the r :0.9
CASE 2 :- enter the r :1
clear all;
N=17;
n=0:1:5;
x=cos(6*pi*n/N + pi/3);
subplot(2,1,1);
stem(n,x); %Plot discrete function
y= fft(x); %Fourier series function
subplot(2,1,2);
stem(n,real(y));
OUTPUT:-
Experiment No. – 7
Aim: . Plot the spectra of ideally sampled signal w.r.t. sampling of
Discrete time signals.
Software Used: MATLAB
Code:-
clc;
clear;
f = 2000;
T = 1/f;
tmin = 0;
tmax = 5*T; % Plot 5 cycles
dt1 = 1/10000;
dt2 = 1/3000;
t1 = tmin:dt1:tmax;
t2 = tmin:dt2:tmax;
x1 = sin(2*pi*f*t1);
x2 = sin(2*pi*f*t2);
subplot(2,1,1);
stem(t1,x1);
subplot(2,1,2);
stem(t2,x2);
OUTPUT:-
Experiment No. – 8
Aim: Plot the magnitude and phase spectra of a signal using Fourier transforms
Software Used: MATLAB
Code:-
clc;
clear;
close all;
A=2;
a=4;
fs=1000; % Sampling frequency
t=0:1/fs:1; %Time
x=A*exp(-a.*t); %Signal
plot(t,x); %Plotting the time domain signal
xlabel('t');
ylabel('x(t)');
title('Time domain Signal')
N=length(x);
N1=2^nextpow2(N);
X=fft(x,N1);
X=X(1:N1/2); %Discard Half of Points
X_mag=abs(X); %Magnitude Spectrum
X_phase=phase(X); %Phase Spectrum
f=fs*(0:N1/2-1)/N1; %Frequency axis
figure
plot(f,(X_mag/N1)); %Plotting the Magnitude Spectrum after Normalization
xlabel('Frequency (Hz)');
ylabel('Magnitude Spectrum');
title('Magnitude Spectrum vs f');
figure
plot(f,X_phase); %Plotting the frequency domain
xlabel('Frequency (Hz)');
ylabel('Phase Spectrum');
title('Phase Spectrum vs f');
OUTPUT:-