You are on page 1of 2

%Activity 2/Maricris Dela Piedra BSCpE-5/DSP

%{
x(t)
= -1 -3<=t<-2
= -t-1 -2<=t<=-1
= 3cos((pi/2)*t) -1<t<=2
%}

ts=0.3;
t1 = -3:ts:-2.1;
f1 = 1*ones(size(t1));
t2 = -1.8:ts:-1.2;
f2 = -t2-1;
t3 = -0.9:ts:0.9;
f3 = 3*cos(pi/2*t3);

%placeholder value added so that limit will be symmetrical both sides.


(-3:3)
tx = 1.2:ts:3;
fx = tx-tx; %zero throughout

subplot(3,1,1);
hold on;
stem(t1,f1,'filled',':x');
stem(t2,f2,'filled','p');
stem(t3,f3,'filled','-.h');
stem(tx,fx,'filled');
hold off;
title('GRAPHING DISCRETE SIGNALS','FontSize',14,'Color','b');
xlabel('n','FontWeight','bold','FontSize',10);
ylabel('x[n]','FontWeight','bold','FontSize',10);
grid on
xlim([-3 3]); ylim([0 3]);
xticks(-3:.3:3);

%%%%%%COMPONENTS%%%%%%%%
X = [t1 t2 t3 tx];
Y = [f1 f2 f3 fx];
even = 0.5*(Y + fliplr(Y));
odd = 0.5*(Y - fliplr(Y));

subplot(3,1,2);
stem(X,even,'-.p');
title('Even Component','FontSize',12,'Color','b');
xlabel('n','FontWeight','bold','FontSize',10);
ylabel('xe[n]','FontWeight','bold','FontSize',10);
grid on
xlim([-3 3]); ylim([0 3]);
xticks(-3:.3:3);

subplot(3,1,3);

1
stem(X,odd,'m:p');
title('Odd Component','FontSize',12,'Color','b');
xlabel('n','FontWeight','bold','FontSize',10);
ylabel('xo[n]','FontWeight','bold','FontSize',10);
grid on
xticks(-3:.3:3);

Published with MATLAB® R2018a

You might also like