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

0% found this document useful (0 votes)
26 views20 pages

Lab4

Uploaded by

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

Lab4

Uploaded by

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

LAB – 4

Name : BARAIYA BHAVESH HIMMATBHAI


Student Id : 202101241
Lab group : 4

Q-1
a)
clear all;
close all;
clc;

n = -10:0.5:10;

i = @(n) n==0;

stem(n,i(n),'.');

xlabel('Time in seconds');
ylabel('i(n)');
title('Descrete time impulse signal');
xlim([-10 10]);
ylim([-1 2]);
b)

clear all;
close all;
clc;

n = -10:0.5:10;
u = @(n) n>=0;

stem(n,u(n),'.');

xlabel('Time in seconds');
ylabel('u(n)');
title('Unit step signal');

xlim([-10 10]);
ylim([-1 2]);
c)

clear all;
close all;
clc;

n = -10:0.5:10;
u = @(n) n>=0;

r = @(n) n.*u(n);

stem(n,r(n),'.r');

xlabel('Time in seconds');
ylabel('r(n)');
title('Unit ramp signal');

xlim([-10 10]);
ylim([-2 10]);
d)

clear all;
close all;
clc;

n = -10:0.1:10;
u = @(n) n>=0;

x = @(n) ((0.5).^n).*u(n);

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('d)');

xlim([-2 5]);
ylim([-1 1.5]);
e)

clear all;
close all;
clc;

n = -10:0.02:10;
u = @(n) n>=0;

x = @(n) ((-1/3).^n).*u(n);

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('e)');

xlim([-1 3]);
ylim([-1 1.5]);
f)

clear all;
close all;
clc;

n = -10:0.05:10;
u = @(n) n>=0;

x = @(n) ((2).^n).*u(-1*n);

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('f)');

xlim([-5 1]);
ylim([-1 3]);
g)

clear all;
close all;
clc;

n = -10:0.05:10;

x = @(n) ((1/2).^abs(n));

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('g)');

xlim([-5 5]);
ylim([-1 3]);
h)

clear all;
close all;
clc;

n = -10:0.5:100;
u = @(n) n>=0;

x = @(n) sin((0.1*pi).*n).*u(n);

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('h)');

xlim([-1 20]);
ylim([-1 3]);
i)

clear all;
close all;
clc;

n = -10:0.05:20;
u = @(n) n>=0;

x = @(n) (0.5.^n).*sin((0.1*pi).*n).*u(n);

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('i)');

xlim([-1 10]);
ylim([-0.5 0.5]);
j)

clear all;
close all;
clc;

n = -100:0.5:100;
u = @(n) n>=0;

x = @(n) (10)*(sin(0.1*pi*n)./(pi*n));

stem(n,x(n),'.');

xlabel('Time in seconds');
ylabel('x(n)');
title('j)');

xlim([-50 50]);
ylim([-0.5 1.5]);
Q–2
a)
clear all;
close all;
clc;

t=-10:0.001:10;

u = @(t) t>=0;

r = @(t) t.*u(t);

x =@(t) (1/6)*r(t+3) - (1/6)*r(t-3) - 1.5*u(t-3) + (1/6)*r(t-3) - (1/6)*r(t-6);

e = (x(t) + x(-t))/2;
o = (x(t) - x(-t))/2;

subplot(2,2,1);
plot(t,x(t));

xlabel('Time in seconds');
ylabel('x(t)');
title('Original signal');

xlim([-5 7]);
ylim([-0.5 1]);

subplot(2,2,2);
plot(t,e);

xlabel('Time in seconds');
ylabel('e(t)');
title('Even part of signal');

xlim([-8 8]);
ylim([-0.5 0.5]);

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

xlabel('Time in seconds');
ylabel('o(t)');
title('Odd part of signal');

xlim([-7 7]);
ylim([-0.5 0.6]);
b)
clear all;
close all;
clc;

t = -10:0.001:10;

u = @(t) t>=0;

r = @(t) t.*u(t);

x = @(t) u(t+2) - (1/2)*r(t-2) + (1/2)*r(t-4);

e = (x(t) + x(-t))/2;
o = (x(t) - x(-t))/2;

subplot(2,2,1);
plot(t,x(t));

xlabel('Time in seconds');
ylabel('x(t)');
title('Original signal');

xlim([-4 5]);
ylim([0 1.2]);

subplot(2,2,2);
plot(t,e);

xlabel('Time in seconds');
ylabel('e(t)');
title('Even part of signal');

xlim([-5 5]);
ylim([0 1.2]);
subplot(2,2,3);
plot(t,o);

xlabel('Time in seconds');
ylabel('o(t)');
title('Odd part of signal');

xlim([-5 5]);
ylim([-0.6 0.6]);
Q–3

:- I have used this functions as individual file

➔ Power function :

function p = P(y)
p=y/2000;
end

➔ Continuous energy function :

function e = continuous_energy(y)
z=@(t) y(t).*y(t);
e=integral(z,-10,10);
end

➔ Descrete energy function :

function ene_des = descrete_energy(y)


total = 0;
for i=-1000:1:1000
total=total+y(i).*y(i);
end
ene_des=total;
end

a)

clear all;
close all;
clc;

t = -1000:0.001:1000;

u = @(t) t>=0;
r = @(t) t.*u(t);

x = @(t) (u(t)-u(t-6)).*sin(4*pi*t);

plot(t,x(t));

energy_of_a = continuous_energy(x)
power_of_a = power(energy_of_a)
xlabel('Time in seconds');
ylabel('x(t)');
title('x(t) signal');

xlim([0 6]);
ylim([-1 1]);

function e = continuous_energy(y)
z=@(t) y(t).*y(t);
e=integral(z,-10,10);
end
function p = power(y)
p=y/2000;
end
b)

clear all;
close all;
clc;

t = -1000:0.001:1000;

u = @(t) t>=0;
r = @(t) t.*u(t);

x = @(t) (1/3)*r(t) - (1/3)*r(t-3) - 2*u(t-3) + (1/3)*r(t-3) - (1/3)*r(t-6);

plot(t,x(t));

energy_of_a = continuous_energy(x)
power_of_a = P(energy_of_a)

xlabel('Time in seconds');
ylabel('x(t)');
title('x(t) signal');

xlim([-1 7]);
ylim([-1.2 1.2]);
c)

clear all;
close all;
clc;

n =-1000:0.1:1000;

u = @(n) n>=0;
r = @(n) n.*u(n);

x = @(n) (1/2).^(abs(n));

stem(n,x(n),'.');

energy_of_a=descrete_energy(x)
power_of_a=P(energy_of_a)

xlabel('Time in seconds');
ylabel('x(n)');
title('x(n) signal');

xlim([-6 6]);
ylim([-0.5 1.2]);
d)

clear all;
close all;
clc;

n =-1000:1:1000;

u = @(n) n>=0;
r = @(n) n.*u(n);

x = @(n) 2*sin(0.1*pi*n) + 10*sin(0.02*pi*n);

stem(n,x(n),'.');

energy_of_a=descrete_energy(x)
power_of_a=P(energy_of_a)

xlabel('Time in seconds');
ylabel('x(n)');
title('x(n) signal');

xlim([-100 100]);
ylim([-13 13]);
e)

clear all;
close all;
clc;

n =-1000:1:1000;

u = @(n) n>=0;
r = @(n) n.*u(n);
x = @(n) 10*sin(0.1*pi*n)./(pi*n);

stem(n,x(n),'.');

energy_of_a=descrete_energy(x)
power_of_a=P(energy_of_a)

xlabel('Time in seconds');
ylabel('x(n)');
title('x(n) signal');

xlim([-40 40]);
ylim([-3 3]);

You might also like