You are on page 1of 6

Cover code

t=0:0.01:5;
x=10*exp(-t)-5*exp(-0.5*t);
plot(t,x);
title('continuous time signal ')
xlabel('t')
ylabel('x(t)')
%%
hold on
x=10*exp(-t)+5*exp(-0.5*t);
plot(t,x);
title('continuous time signal ')
xlabel('t')
ylabel('x(t)')
hold off

%%
t=linspace(-0.002,0.002);
a1=250;
a2=500;
a3=750;
a4=100;
y1=20*sin(2*pi*1000*t-pi/3).*exp(-a1.*t);
y2=20*sin(2*pi*1000*t-pi/3).*exp(-a2.*t);
y3=20*sin(2*pi*1000*t-pi/3).*exp(-a3.*t);
y4=20*sin(2*pi*1000*t-pi/3).*exp(-a4.*t);
subplot(2,2,1);
plot(t,y1);
title('sinusoidal signal')
xlabel('t')
ylabel('y(t)')
subplot(2,2,2);
plot(t,y2);
title('sinusoidal signal')
xlabel('t')
ylabel('y(t)')
subplot(2,2,3);
plot(t,y3);
title('sinusoidal signal')
xlabel('t')
ylabel('y(t)')
subplot(2,2,4);
plot(t,y4);
title('sinusoidal signal')
xlabel('t')
ylabel('y(t)')

%%
Magnitude_x1 = abs(x1);
subplot(2,1,1)
stem(k,Magnitude_x1)
Phase_x1 = angle(x1);
subplot(2,1,2)
stem(k,Phase_x1
function y=impulseDT(n)

y = (n == 0);

ss = find(round(n) == n);

if(~isempty(ss))

n(ss) = NaN;

end

end

%%

function y = unitDT(n)

y = (n >= 0);

ss = find(round(n) == n);

if(~isempty(ss))

n(ss) = NaN;

end

end

%%

function y = rampDT(n)

pos = (n > 0);

y = n.*pos;

ss = find(round(n) ~= n);

if (~isempty(ss))

y(ss)=NaN;

end
end

%%

n = -10 : 1 : 10;

s1n = impulseDT(n-3);

s2n = 2.*impulseDT(n-3)+ impulseDT(n+8);

s3n = unitDT(n+2) - unitDT(n-5);

s4n = unitDT(n+2) + impulseDT(n-5);

s5n = unitDT(n-4) - impulseDT(n-3).*n.^2;

s6n = rampDT(n) - 2.*rampDT(n-2) + rampDT(n-4);

subplot(6,3,1);

stem(n,s1n);

subplot(6,3,2);

stem(n,s2n);

subplot(6,3,3);

stem(n,s3n);

subplot(6,3,4);

stem(n,s4n);

subplot(6,3,5);

stem(n,s5n);

subplot(6,3,6);

stem(n,s6n);

%%

n = -10 : 0.1 : 10;

x1n = exp(-2*n).*(unitDT(n)-unitDT(n-4));
x1n_sq = x1n.*x1n;

Ex = sum(x1n_sq);

disp(['The energy of the signal is: ', num2str(Ex)]);

x2n = exp(-1*n).*(unitDT(n)-unitDT(n-4));

x2n_sq = x2n.*x2n;

Ex = sum(x2n_sq);

disp(['The energy of the signal is: ', num2str(Ex)]);

%%

n = -15 : 0.1 : 15;

x3n = cos(pi*n/3).*(unitDT(n)-unitDT(n-4));

x3n_sq = x3t.*x3n;

Ex = sum(x3t_sq);

disp(['The energy of the signal is: ', num2str(Ex)]);

Px = Ex/length(t); % Power

disp(['Power of the signal is : ', num2str(Px)]);

n = -12 : 0.1 : 12;

x4n = ((-1)^n)/3).*unitDT(n);

x4n_sq = x4n.*x4n;

Ex = sum(x4n_sq);

disp(['The energy of the signal is: ', num2str(Ex)]);

Px = Ex/length(n); % Power

disp(['Power of the signal is : ', num2str(Px)]);

%%

n = -12 : 12;

gn= (abs(1i/4)^n).*unitDT(n);

gEven = (gDisc(n) + gDisc(-1*n))/2;

gOdd = (gDisc(n) - gDisc(-1*n))/2;

figure('even')

stem(n, (gDisc(n) + gDisc(-1*n))/2)


figure('odd')

stem(n, (gDisc(n) - gDisc(-1*n))/2)

You might also like