Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views7 pages

Lab 2 Data

Data communication lab 2

Uploaded by

adityadhital7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Lab 2 Data

Data communication lab 2

Uploaded by

adityadhital7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

write a matlab program to find to find the even and odd parts of the

signal x(t)=e^2t
t = -3:0.1:3;

t = -3:0.1:3;

x1 = exp(2*t);

x2 = exp(-2*t);

if(x1==x2)

disp('even signal')

elseif(x2==(-x1))

disp('odd signal')

else

disp('neither even nor odd signal')

end

x_e = 0.5 * (x1 + x2);

x_o = 0.5 * (x1 - x2);

subplot(2,2,1);

plot(t, x1);

title('input sequence x1(t)');

xlabel('Time (t)');

ylabel('amplitude)');

subplot(2,2,2);

plot(t, x2);

title('input sequence x2(t)');

xlabel('Time (t)');

ylabel('amplitude)');

subplot(2,2,3);
plot(t, x_e);

title('Even Part x_e(t)');

xlabel('Time (t)');

ylabel('x_e(t)');

subplot(2,2,4);

plot(t, x_o);

title('Odd Part x_o(t)');

xlabel('Time (t)');

ylabel('x_o(t)');

write a matlab program to find to find the energy and power of the signal
x(t)=10sin(10pi*t)
t = -10:0.01:10;
T=10

x = 10 * sin(10 * pi * t);

x_sq=x.^2

energy = trapz(t, x_sq=x.^2 );

power = energy / (2*T);

disp(['Energy of the signal: ', num2str(energy),'joules']);

disp(['Power of the signal: ', num2str(power),'watt']);

output:
Energy of the signal: 1000joules
Power of the signal: 50watt

write a matlab program to perform amplitude scaling ,time scaling, time


shift on the signal x(t) = 1 + t for t = 0 to 2

t = -3:0.1:5;

x = @(t) (1+t).*(t>=0 & t<=2);

y0 = x(t);

y1 = 1.5*x(t);

y2 = 0.5*x(t);

y3 = x(2*t);

y4 = x(0.5*t);

y5 = x(t-2);

y6 = x(t+2);

subplot(4,2,1);

plot(t,y0);

xlabel('Time -t');

ylabel('Amplitude');

title('Input sequence x(t)');


subplot(4,2,2);

plot(t,y1);

xlabel('Time -t');

ylabel('Amplitude');

title('Amplification of x(t)');

subplot(4,2,3);

plot(t,y2);

xlabel('Time -t');

ylabel('Amplitude');

title('Attenuation of x(t)');

subplot(4,2,4);

plot(t,y3);

xlabel('Time -t');

ylabel('Amplitude');

title('compression of x(t)');

subplot(4,2,5);

plot(t,y4);

xlabel('Time -t');

ylabel('Amplitude');

title('Expansion x(t)');

subplot(4,2,6);

plot(t,y5);
xlabel('Time -t');

ylabel('Amplitude');

title('Delay of x(t)');

subplot(4,2,7);

plot(t,y6);

xlabel('Time -t');

ylabel('Amplitude');

title('Advance of x(t)');

%write a matlab program to perform addition and multiplication of two


signals
%x1(t) = 1: 0<t<1

% = 2: 1<t<2
% = 1: 2<t<3

%x2(t) = t: 0<t<1

% = 1: 1<t<2

% = 3-t: 2<t<3

tmin = -1; tmax = 5; dt = 0.1;

t= tmin:dt:tmax;

x1 = 1;

x2 = 2;

x3 = 3 - t;

xa = x1.*(t>0 & t<1) + x2.* (t>=1&t<=2) +x1.*(t>2 & t < 3);

xb = t.*(t>0 & t < 1) + x1.*(t>=1 & t<=2) + x3 .*(t>2 & t<3);

xadd = xa + xb;

xmul = xa .* xb;

xsub = xa - xb;

xdiv = xa ./ xb;

xmin = min([min(xa), min(xb),min(xadd),min(xmul)]);

xmax = max([max(xa), max(xb),max(xadd),max(xmul)]);

subplot(2,3,1);plot(t,xa);axis([tmin tmax xmin xmax]);

xlabel('t');ylabel('xa(t)');title('Signal xa(t)');

subplot(2,3,2);plot(t,xb);axis([tmin tmax xmin xmax]);

xlabel('t');ylabel('xb(t)');title('Signal xb(t)');

subplot(2,3,3);plot(t,xadd);axis([tmin tmax xmin+0.5 xmax+0.5]);


xlabel('t');ylabel('xadd(t)');title('Signal xadd(t)');

subplot(2,3,4);plot(t,xmul);axis([tmin tmax xmin+0.5 xmax+0.5]);

xlabel('t');ylabel('xmul(t)');title('Signal xmul(t)');

subplot(2,3,5);plot(t,xsub);axis([tmin tmax xmin xmax]);

xlabel('t');ylabel('xsub(t)');title('Signal xsub(t)');

subplot(2,3,6);plot(t,xdiv);axis([tmin tmax xmin xmax]);

xlabel('t');ylabel('xdiv(t)');title('Signal xdiv(t)');

You might also like