DLDEXPALL
DLDEXPALL
DLDEXPALL
Output:
C=
2 4 6
5 8 12
9 12 16
D=
0 0 0
1 0 -2
3 2 0
E=
14 25 41
26 47 77
44 80 131
F=
1.0000 0 0
1.0000 -2.0000 2.0000
1.0000 -5.0000 5.0000
G=
1.0e+015 *
-2.7022 4.5036 -1.8014
5.4043 -9.0072 3.6029
-2.7022 4.5036 -1.8014
H=
1 4 9
6 16 35
18 35 64
A_transpose =
1 3 6
2 4 7
3 5 8
B_transpose =
1 2 3
2 4 5
3 7 8
K =0
L=1
V=
-0.2656 -0.7444 0.4082
-0.4912 -0.1907 -0.8165
-0.8295 0.6399 0.4082
E=
14.0664 0 0
0 -1.0664 0
0 0 -0.0000
V=
-0.2797 -0.2360 - 0.4332i -0.2360 + 0.4332i
-0.6148 0.7650 0.7650
-0.7374 -0.3864 + 0.1486i -0.3864 - 0.1486i
E=
13.3063 0 0
0 -0.1531 + 0.2274i 0
0 0 -0.1531 - 0.2274i
Experiment 2
Aim: Write a MATLAB program to generate Various Signals and Sequences (Periodic and
Aperiodic) such as Unit Impulse, Unit Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp,
and Sinc function.
Apparaters: Personal computer and MATLAB software.
PROGRAM:
clear all
t=-1:.01:1;
x1=sin(2*pi*1.5*t);
subplot(3,3,1);
plot(t,x1);
xlabel('----> t ');
ylabel('x1(t)');
title(' sinusoidal signal');
N=31;
x1=ones(1,N);
n=0:1:N-1;
subplot(2,2,1);
stem(n,x1);
xlabel('n ');
ylabel('x1(n)');
title('unit step sequence');
Output Waveforms:
%to generate unit ramp sequence %
n=0:1:10;
x1=n ;
subplot(3,1,1);
stem(n,x1);
xlabel('n ');
ylabel('x1(n)');
title('unit ramp sequence');
Output Waveforms:
Experiment 3
Aim: Write a MATLAB program to perform Operations on Signals and Sequences such as
Addition, Multiplication, Scaling, Shifting, Folding, Computation of Energy and Average
Power.
Apparaters: Personal computer and MATLAB software.
PROGRAM:
% input sequence 1 %
n=0:1:3;
x=[1,2,2,3];
n1=length(x);
subplot(2,2,1);
stem(n,x);
xlabel('n');
ylabel('input sequence1');
% input sequence 2 %
n=0:1:3;
y=[1,6,4,3];
n2=length(y);
subplot(2,2,2);
stem(n,y);
xlabel('n');
ylabel('input sequence 2');
% addition of x and y %
n=0:1:6;
r1=x+y;
subplot(2,2,3);
stem(r1);
xlabel('n');
ylabel('addition of x and y ');
Output Waveforms:
% ADDITION OF TWO SINUSOIDAL SIGNALS %
clc;
t=0:.01:pi;
y1=sin(2*pi*t);
subplot(3,1,1);
plot(t,y1);
title('sinusoidal signal 1');
y2=cos(3*pi*t);
subplot(3,1,2);
plot(y2);
title('sinusoidal signal 2');
h=y1+y2;
subplot(3,1,3);
plot(h);
title('addition of two sinusoidal signals');
Output Waveforms:
% TIME SCALING ,TIME SHIFTING %
clear all;
tmin=-15;
tmax=20;
t=tmin:.1:tmax;
y0=y(t);
y1=y(t+4);
y2=2*y(t-3);
y3=y(2*t);
y4=y(2*t-3);
y5=y(t/2);
y6=y(-t);
ymax=max([max(y0),max(y1),max(y2),max(y3),max(y4),max(y5)]);
ymin=min([min(y0),min(y1),min(y2),min(y3),min(y4),min(y5)]);
subplot(3,2,1),plot(t,y0);
xlabel('t'),ylabel('y0');
axis([tmin tmax ymin ymax]);
subplot(3,2,2),plot(t,y1);
xlabel('t'),ylabel('y1');
axis([tmin tmax ymin ymax]);
subplot(3,2,3),plot(t,y2);
xlabel('t'),ylabel('y2');
axis([tmin tmax ymin ymax]);
subplot(3,2,4),plot(t,y3);
xlabel('t'),ylabel('y3');
axis([tmin tmax ymin ymax]);
subplot(3,2,5),plot(t,y4);
xlabel('t'),ylabel('y4');
axis([tmin tmax ymin ymax]);
subplot(3,2,6),plot(t,y5);
xlabel('t'),ylabel('y5');
axis([tmin tmax ymin ymax]);
function x=y(t);
x1=t+5;
x2=11+4*t;
x3=24-9*t;
x4=t-6;
x=x1.*(-5<t&t<=-2)+x2.*(-2<t&t<=1)+x3.*(1<t&t<=3)+x4.*(3<t&t<=-6);
Output Waveforms:
Experiment 4
Aim: Write a MATLAB program to Find a) Even and Odd parts of a Signal b) Real and
Imaginary parts of a signal
PROGRAM:
clear all; clc; close all; % Clear workspace, command window, and close all figures
t = -10:0.01:10; % Define time vector from -10 to 10 with a step size of 0.01
% Define the given signal y(t)
y0 = y(t);
% Time reversal of the signal
y1 = y(-t);
% Find maximum and minimum values for setting y-axis limits
ymax = max([max(y0), max(y1)]);
ymin = min([min(y0), min(y1)]);
% Plotting the original and time-reversed signals
subplot(4, 2, 1), plot(t, y0);
xlabel('t');
ylabel('y(t)');
title('Original Signal');
subplot(4, 2, 2), plot(t, y1);
xlabel('t');
ylabel('y(-t)');
title('Time-Reversed Signal');
% Even part of the signal
ye = (y0 + y1) / 2;
% Odd part of the signal
yo = (y0 - y1) / 2;
% Plotting the even and odd parts
subplot(4, 2, 3), plot(t, ye);
xlabel('t');
ylabel('y_e(t)');
title('Even Part of Signal');
subplot(4, 2, 4), plot(t, yo);
xlabel('t');
ylabel('y_o(t)');
title('Odd Part of Signal');
% Shifting the signal by 2 units to the right
subplot(4, 2, 5), plot(t, y(t - 2));
xlabel('t');
ylabel('y(t-2)');
title('Shifted Right by 2 units');
% Shifting the signal by 2 units to the left
subplot(4, 2, 6), plot(t, y(t + 2));
xlabel('t');
ylabel('y(t+2)');
title('Shifted Left by 2 units');
% Stretching the signal horizontally by a factor of 2
subplot(4, 2, 7), plot(t, y(t * 2));
xlabel('t');
ylabel('y(t*2)');
title('Time Scaling (t*2)');
OUTPUT:
Experiment 5
Aim: Write a MATLAB program to find the Convolution between Signals and Sequences.
Apparaters: Personal computer and MATLAB software.
PROGRAM:
% Convolution of two given sequences x and h%
clear all
x=[1,2,1,2,1,3,2];
N1=length(x);
n=0:1:N1-1;
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
title('input sequence of x(n)');
h=[1,-1,2,-2,1,1];
N2=length(h);
n1=0:1:N2-1;
subplot(2,2,2),stem(n1,h);
xlabel('n'),ylabel('h(n)');
title('impulse sequence of x(n)');
y=conv(x,h)
n2=0:1:N1+N2-2;
subplot(2,1,2),stem(n2,y);
xlabel('n'),ylabel('y(n)');
title('Convolution of two sequences of x(n) and h(n)');
OutputWaveforms:
% Convolution of 2 signals %
clc;
t=0:.01:pi;
y1=sin(2*pi*t);
subplot(3,1,1);
plot(t,y1);
y2=cos(3*pi*t);
subplot(3,1,2);
plot(y2);
h=conv(y1,y2);
subplot(3,1,3);
plot(h);
OutputWaveforms:
Experiment 6
Aim: Write a MATLAB program to find the Auto Correlation and Cross Correlation of two
Signals and Sequences.
Apparaters: Personal computer and MATLAB software.
PROGRAM:
% input sequence1 %
n=0:1:3;
x=[1,2,2,3];
n1=length(x);
subplot(2,2,1),stem(n,x);
xlabel('n'); ylabel('input sequence');
% input sequence2 %
n=0:1:3;
y=[1,6,4,3];
n2=length(y);
subplot(2,2,2);
stem(n,y);
xlabel('n');
ylabel('input sequence');
n=0:1:6;
r1=xcorr(x,x);
subplot(2,2,3), stem(r1);
xlabel('n'); ylabel('ACR sequence');
n=0:1:6;
r2=xcorr(x,y);
subplot(2,2,4), stem(r2);
xlabel('n');
ylabel('CCR sequence');
Output Waveforms:
% ACR and CCR OF TWO SINUSOIDAL SIGNALS%
% crosscorrelation of x and y %
n=0:1:6;
r2=xcorr(x1,x2);
subplot(4,1,4), stem(r2);
xlabel('n');
ylabel('crosscorrelation of x and y');
Output Waveforms:
Experiment 7
% Sampling Theorem %
clc;
clear all;
close all;
t=-100:.01:100;
fm=.02;
x=cos(2*pi*t*fm);
subplot(2,2,1),plot(t,x);
xlabel('time in sec'),ylabel('x(t)');
title('continous time signal');
fs1=.02;
n=-2:2;
x1=cos(2*pi*fm*n/fs1);
subplot(2,2,2),stem(n,x1);
hold on
subplot(2,2,2);
plot(n,x1);
title('discrete time signal x(n) with fs<2fm');
xlabel('n'),ylabel('x(n)');
fs2=0.04;
n1=-4:4;
x2=cos(2*pi*fm*n1/fs2);
subplot(2,2,3),stem(n1,x2);
hold on
subplot(2,2,3);
plot(n1,x2);
title('discrete time signal x(n) with fs=2fm');
xlabel('n'),ylabel('x(n)');
n2=-50:50;
fs3=.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(2,2,4),stem(n2,x3);
hold on
subplot(2,2,4);
plot(n2,x3);
title('discrete time signal x(n) with fs>2fm');
xlabel('n'),ylabel('x(n)');
Output Waveforms: