fianl destination
TRANSCRIPT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 1/34
exp -1) generation of unit impulse and unit step signal and sequence
%unit impulse generation and sequence
clc
close all
t=-1:0.01:1;x=(t==0);
subplot(1,2,1)
plot(t,x)
xlabel('n');
ylabel('amplitude');
title('unit impluse signal');
subplot(1,2,2)stem(t,x,'fill')
xlabel('n');
ylabel('amplitude');
title('unit impulse sequence');
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 2/34
% generation of unit step signal and sequence
n=-1:0.03:1;
y=(n>=0)
figure;
subplot(1,2,1)
plot(n,y)
grid
title('unit step signal');
xlabel('time');
ylabel('amplitude');
subplot(1,2,2)
stem(n,y);
gridtitle('unit step sequence');
xlabel('time');
ylabel('amplitude');
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 3/34
exp -2) generation of square and sawtooth signal and sequence
% sawtooth wave generator and sequence
fs=10000;
t=0:1/fs:1.5;
x=sawtooth(2*pi*50*t);
subplot(1,2,1);
plot(t,x);
axis([0 0.2 -1 1]);
xlabel('t');
ylabel('x(t)');
title('sawtooth signal');
N=2;
fs=500;
n=0:1/fs:2;
x=sawtooth(2*pi*50*n);
subplot(1,2,2);
stem(n,x);
axis([0 0.2 -1 1]);
xlabel('n');
ylabel('x(n)');
title('sawtooth sequence');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 4/34
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 5/34
%square wave generator and sequence
fs=500;
t=0:1/fs:1.5;
x1=square(2*pi*50*t);
subplot(1,2,1);
plot(t,x1);
axis([0 0.2 -1.2 1.2])
xlabel('time(sec)');
ylabel('amplitude');
subplot(1,2,2);
stem(t,x1);axis([0 0.2 -1.2 1.2])
xlabel('time(sec)');
ylabel('amplitude');
title('square wave sequence')
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 6/34
exp -3) generation of ramp signal and sequence
%to generate ramp signal
close all
t=0:1:20;
y=t;subplot(1,2,1)
plot(t,y);
xlabel('t');
ylabel('amplitude');
title('ramp signal')
subplot(1,2,2)
stem(t,y);xlabel('t');
ylabel('amplitude');
title('ramp sequence')
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 7/34
exp -4)generation of sinusoidal and sinc signal and
sequence
%to generate a sinusoidal signal
N=64; %define no. of samplesn=0:N-1; %define vector n=0,1,2,3, .... 63
f=500; %define the frequency
fs=8000; %define the sampling frequency
x=sin(2*pi*(f/fs)*n); % generate x(t)
plot(n,x);
title('sinewave [f=1khz, fs=8khz]');
xlabel('sample number');
ylabel ('amplitude');
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 8/34
%to generate sinc function
x=linspace(-5,5);
y=sinc(x);
subplot(1,2,1);
plot(x,y)xlabel('time');
ylabel('amplitude');
title('sinc function');
subplot(1,2,2);
stem(x,y);
xlabel('time');
ylabel('amplitude');
title('sinc function');
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 9/34
exp -5) to perform addition and multiplication of unit
step and sinusoidal signal and sequence
%program for addition and multiplication of unit step signal
and sequence
n1=1:1:9;
s1=[1 2 3 4 5 6 2 3 1];
subplot(4,1,1)
stem(n1,s1)xlabel('n1')
title('input sequence')
ylabel('amplitube')
n2=-2:1:6;
s2=[1 1 1 0 2 3 1 1 0 ];
subplot(4,1,2)
stem(n2,s2)xlabel('n2')
title('second sequence')
ylabel('amplitube')
xlabel('n2')
s3=s1+s2;
subplot(4,1,3);
stem(n2,s3)title('summed sequence')
ylabel('amplitube')
xlabel('n2')
s4=s1.*s2;
subplot(4,1,4);
stem(n2,s4)
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 10/34
title('multiplication')
ylabel('amplitube')
xlabel('n2')
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 11/34
%program for addition and multiplication of sinusoidal signal
and sequence
t=[0:0.01:1];
A=8;
f1=2;
s1=A*sin(2*pi*f1*t);
f2=2;
s2=A*sin(2*pi*f2*t);
figuresubplot(4,1,1)
plot(t,s1)
title('1 hz sine wave')
ylabel('amplitude')
%plot the 4 hz sine wave
subplot(4,1,2)
plot(t,s2)title('2 hz sine wave')
ylabel('amplitude')
%plot the summed sine wave
subplot(4,1,3);
plot(t,s1+s2)
title('summed sine wave')
ylabel('amplitude')xlabel('time(s)')
xmult=s1.*s2;
subplot(4,1,4)
plot(xmult);
title('multiplication');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 12/34
ylabel('amplitude')
xlabel('time(s)')
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 13/34
exp -6)To perform addition and multiplication of ramp signal and
sequence
% To perform addition and multiplication of ramp signal and sequence
t = -20:20;
i=1;
for k=-20:20
if k>0
ramp1(i) = k;
elseramp1(i) = 0;
end
i = i+1;
end
subplot(2,2,1);
stem(t,ramp1);
xlabel('Time');
ylabel('Ramp signal 1');grid on;
t = -20:20;
i=1;
for k=-20:20
if k>0
ramp2(i) = k;
else
ramp2(i) = 0;end
i = i+1;
end
subplot(2,2,2);
stem(t,ramp2);
xlabel('Time');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 14/34
ylabel('Ramp signal 2');
grid on;
x_addition=ramp1+ramp2;
subplot(2,2,3);
plot(t,x_addition);
grid on;
xlabel('Time');
ylabel('Added Signal');
x_multiplication=ramp1.*ramp2;
subplot(2,2,4);
plot(t,x_multiplication);
grid on;
xlabel('Time');
ylabel('Multiplied Signal');
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 15/34
exp -7) to perform amplitude scaling for signal and sequence
% ampllitude scalling
t=[0:0.01:1];a=8;
f1=2;
s1=A*sin(2*pi*f1*t);
subplot(3,1,1)
plot(s1);
xlabel('t');
ylabel('ampltude');title('input signal');
s2=2*s1;
subplot(3,1,2)
plot(s2);
xlabel('t');
ylabel('ampltude');
title('amplified input signal');s3=s1/2;
subplot(3,1,3)
plot(s3);
xlabel('t');
ylabel('ampltude');
title('atteniated input signal');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 16/34
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 17/34
exp-8) to generate complex valued signal and plot its magnitude,
phase, real and imaginary part in four separate subplots
%even and odd parts
close all;
clear all;
t=0:.005:4*pi;
x=sin(t)+cos(t) % x(t)=sint(t)+cos(t)
subplot(2,2,1)
plot(t,x)
xlabel('t');
ylabel('amplitude')
title('input signal')
y=sin(-t)+cos(-t) % y=x(-t)
subplot(2,2,2)
plot(t,y)
xlabel('t');
ylabel('ampitude')
title('input signal with t=-t')
z=x+y
subplot(2,2,3)
plot(t,z/2)
xlabel('t');
ylabel('amplitude')
title('even part of the signal')
p=x-y
subplot(2,2,4)
plot(t,p/2)
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 18/34
xlabel('t');
ylabel('amplitude')
title('odd part of the signal')
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 19/34
exp-9) to perform linear convolution between signals and
sequences
%linear convolution
clc;
close all;
clear all;
x=input('enter input sequence');
h=input('enter impulse response');y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('h(n)');
title('input signal');
subplot(3,1,2);stem(h);
xlabel('n');
ylabel('y(n)');
title('impulse response');
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title('linear convolution');
disp('The resultant sighnal is');
disp(y)
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 20/34
OUTPUTenter input sequence1432
enter impulse response1021
The resultant sighnal is
1462072
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 21/34
exp-10) to find the Fourier transform of a given signal
and plotting its magnitude and phase spectrum
% fast Fourier transform (magnitude and phase plot)
clc;
close all;
X=[1,1,1,1,zeros(1,4)];
N=8;
X=fft(X,N);
magX=abs(X),phase=angle(X)*180/pi;
subplot(2,2,1);
plot(magX);
grid
xlabel('k')
ylabel('X(k)')
subplot(2,1,2)
plot(phase);
grid
xlabel('k')
ylabel('degrees')
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 22/34
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 23/34
exp -11)to find auto correlation and cross correlation
between signals and sequence
%cross correlation
close all;
clear all;
x=input('enter input sequence');
h=input('enter impulse sequence');
subplot(3,1,1);stem(x);
xlabel('n');ylabel('x(n)');
title('input signal');
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');title('impulse signal');
y=xcorr(x,h);
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
disp('the resultant sigal is');disp(y);
title('correlation signal');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 24/34
OUTPUT
enter input sequence12
enter impulse sequence3
the resultant sigal is
0
0
0
1440
0
0
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 25/34
%autocorrelation
clc;
close all;
clear all;x=[1,2,3,4,5];
y=[4,1,5,2,6];
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input signal');
subplot(3,1,2);
stem(y);
xlabel('n');
ylabel('y(n)');
title('input signal');
z=xcorr(x,x);
subplot(3,1,3);
stem(z);
xlabel('n');
ylabel('z(n)');
title('resultant signal signal');
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 26/34
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 27/34
exp -12) verification of linearity and time invariance properties of a
given continuous/discrete system
%LINEARITY PROPERTY
clc;
clear all;
close all;
n=0:40; a=2; b=1;x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=n.*x;
y1=n.*x1;
y2=n.*x2;
yt=a*y1+b*y2;d=y-yt;
d=round(d);
if d==0
disp('given system satisfies linearity properity');
else
disp('given system doesn’t satisfy linearity property');
endsubplot(3,1,1); stem(n,y); grid;
subplot(3,1,2); stem(n,yt); grid;
subplot(3,1,3); stem(n,d); grid;
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 28/34
OUTPUT
Given system satisfies linearity property
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 29/34
%FOR NON LINEAR SYSTEM
clc;
clear all;
close all;
n=0:40; a=2; b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=x.^2;
y1=x1.^2;
y2=x2.^2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d);
if d==0
disp('given system satisfies linearity properity');else
disp('given system doesn’t satisfy linearity property');
end
subplot(3,1,1); stem(n,y); grid;
subplot(3,1,2); stem(n,yt); grid;
subplot(3,1,3); stem(n,d); grid;
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 30/34
OUTPUT
given system satisfies doesn’t linearity property
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 31/34
exp -13) to perform waveform synthesis using Laplace
transform
% laplace transform programs
clc;close all;
clear all;
syms t w s;
f1=sin(w*t);
f2=sin(w*(t-1));
v1=laplace(f1);
v2=laplace(f2);disp('v1=')
pretty(v1);
disp('v2=')
pretty(v2);
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 32/34
% INVERSE laplace transform programs
close all;
clear all;syms F s;
F=24/(s*(s+8));
iLaplace(F)
OUTPUT
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 33/34
exp -14) to perform image operations ;- read, resize,
rotate, and rgb to grayscale.
basicimageprocessing
% reading image...
A=imread('tanmay.jpg');
figure(1):imshow(A);
% resizing image....
B=imresize(A,[60,60]);
figure(2):imshow(B);
% color conversion..from rgb to grayscale image...
C=rgb2gray(A);
figure(3):imshow(C);
% rotating image....
D=imrotate(A,45);
figure(4):imshow(D);
8/2/2019 Fianl Destination
http://slidepdf.com/reader/full/fianl-destination 34/34
Output