0% found this document useful (0 votes)
63 views9 pages

Activity#4 (Create A Discrete-Time Signal With EVEN & ODD) : 1. Objectives

This document contains the code and summary for a student's activity on plotting even and odd components of a discrete-time signal. The student defines a piecewise function with 6 limits between -5 and 5 and plots it. Then, the even component is calculated as the average of the function and its time-reversed version and plotted. Similarly, the odd component is calculated and plotted. The code thoroughly labels the plots and axes.

Uploaded by

JoevelleBaflor
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)
63 views9 pages

Activity#4 (Create A Discrete-Time Signal With EVEN & ODD) : 1. Objectives

This document contains the code and summary for a student's activity on plotting even and odd components of a discrete-time signal. The student defines a piecewise function with 6 limits between -5 and 5 and plots it. Then, the even component is calculated as the average of the function and its time-reversed version and plotted. Similarly, the odd component is calculated and plotted. The code thoroughly labels the plots and axes.

Uploaded by

JoevelleBaflor
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/ 9

Name: Joevelle Zabate Baflor Instructor: Engr.

Joseph Manbert Mendez, REcE


Subject: ECE415 (SPECTRA) Date: July 08, 2017

Activity#4 (Create a Discrete-Time Signal


with EVEN & ODD)

1. Objectives:

Even Signals: x(t) = x(t), x[n] = x[n]


To plot the even and the odd component of
a discrete-time signal.

2. Discussion (Manual Plotting): Odd Signals: x(t) = x(t), x[n] = x[n]

A discrete signal or discrete-time


signal is a timeseries consisting of a To be able to compute the even and odd

sequence of quantities. Unlike a components of a signal, we must reverse


the y-component of the function and
continuous-time signal, a discrete-
apply the formula. Suppose we have a
time signal is not a function of a
signal (n,xn) and the time reversed
continuous argument; however, it
version, xN. We can obtain xN by using
may have been obtained by
the fliplr (short for flip left-right)
sampling from a continuous-time function as follows.
signal.
xN = fliplr(xn);
Even and odd signals bear some
important symmetry properties. Under
For longer vectors (signals) this method
reversal of independent variable, these
would be definitely better than writing the
signals either remain the same (even
whole signal in reverse order.
signal) or get reflected or flipped (odd
signal) about the horizontal axis.
Equations or definitions mathematically
This is my piecewise function to be graph in MatLab
express these properties for both

continuous and discrete time cases. ( ) + ( )

(. )
.
() =
( )

<

{ ( ) ( ) <

Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

Codes

% MY PIECEWISE FUNCTION ( ACTIVITY #4)


% DISCRETE-TIME SIGNAL (ODD & EVEN SIGNAL)
% MINIMUM OF 6 LIMITS

%% -cos (pi/6)t + (pi/6) -5 <= t <= -4


% (-2t^(1.25))-12 -4 <= t <= -3
% t^(1.5) -3 <= t <= 0
% 2 sin(pi/2)t 0 <= t <= 3
% -2 3 < t <= 4
% -cos (pi/6)t - (pi/6) 4 < t <= 5
%% =================================

x1=-5:.25:-4; % MY RANGE FOR THE 1st FUNCTION


y1=-cos(((pi/6)*x1)+(pi/6)); % THE EQUATION OF MY 1st LIMIT
x2=-4:.25:-3; % MY RANGE FOR THE 2nd FUNCTION
y2=(-2*x2*1.25-12); % THE EQUATION OF MY 2nd LIMIT
c1=[-4:0.75:-4]; % CONSTANTS
t1=[-2:0.75:0]; % CONSTANTS
x3=-3:.30:0; % MY RANGE FOR THE 3rd FUNCTION
y3=x3*1.5; % MY EQUATION OF MY 3rd LIMIT
x4=0:.30:3; % MY RANGE FOR THE 4th FUNCTION
y4=sin((pi/2)*x4); % MY EQUATION OF MY 4th LIMIT
x5=[3 3]; % CONSTANTS
y5=[-1 -2]; % CONSTANTS
x6=[3:0.25:4]; % MY LIMITS FOR THE 5th FUNCTION
y6=[-2:0.25-2]; % x(t) = -2
x7=[4:0.25:4]; % CONSTANTS
y7=[-2:0.75:0]; % CONSTANTS
x10=4:.25:5; % MY FINAL LIMIT FOR THE 6th FUNCTION
y10=-cos(((pi/6)*x10)-(pi/6)); % MY LAST EQUATION
%% ===================================
% THIS SECTION WHERE I CREATE MY PLOTS FOR THE SPECIFIED WINDOW or FIGURE
figure
subplot (3,1,1);
plot(x1,y1,'-o',x2,y2,'-o',x3,y3,'-o',x4,y4,'-o',x5,y5,'-o',x6,y6,'-o',x7,y7,'-o',x10,y10,'-
o',c1,t1,'-o');

xlabel('n'); %% Label for X-Axis


ylabel('x[n]'); %% Label for Y-Axis
title ({'ACTIVITY #4','DISCRETE-TIME SIGNAL'}); % DISPLAYS TITLE

axis([-5.8 5.8 -5.25 2]) %% MY AXES LIMITS


grid minor; %% GRID FOR BETTER ACCURACY READING
grid on; %% ENABLE GRID FOR BETTER VIEW
zoom on; %% ENABLE THE USER TO NAVIGATE ZOOM-IN and OUT
%% END OF PLOT FOR DISCRETE SIGNAL

% CODE FOR EVEN DISCRETE-TIME SIGNAL


% USING THE FORMULA Xe(t) = 1/2 (x(t) + x(-t))
Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

%% x[n] at negative values for t = 0.35

xe1=-5:0.35:-4;
xe2=-4:0.35:-3;
xe3=-3:0.35:0;

%% x[n] at positive values for t = 0.35

xe4=4:0.35:5;
xe5=3:0.35:4;
xe6=0:0.35:3;

%% PLUG-IN VALUES OF x(t) and x(-t)

x1a=-cos(((pi/6)*xe1)+(pi/6));
x1b=-cos(((pi/6)*xe4)-(pi/6));
x2a=(-2*xe2*1.25-12);
x2b=-2;
x3a=xe3*1.5;
x3b=sin((pi/2)*xe6);

%% FOR PLOTTING using Xe(t) = 1/2 ( x(t) + (x-t))

e1=(1/2)*(x1a+x1b);
e2=(1/2)*(x2a+x2b);
e3=(1/2)*(x3a+x3b);
e4=(1/2)*(x1b+x1a);
e5=(1/2)*(x2b+x2a);
e6=(1/2)*(x3b+x3a);

%% Creating the plots in a single figure position row 2, 'o-' as an indicator

subplot(3,1,2);

stem(xe1,e1,'filled');
hold on;
stem(xe2,e2,'MarkerFaceColor','black');
hold on;
stem(xe3,e3,'MarkerFaceColor','green');
hold on;
stem(xe4,fliplr(e4),'MarkerFaceColor','yellow');
hold on;
stem(xe5,fliplr(e5),'MarkerFaceColor','magenta');
hold on;
stem(xe6,fliplr(e6),'MarkerFaceColor','blue');

xlabel('n'); %% Label for X-Axis


ylabel('x[n]'); %% Label for Y-Axis
title ({'ACTIVITY #4','EVEN -- DISCRETE-TIME SIGNAL'}); % DISPLAYS TITLE

axis([-5.25 5.25 -3.5 1]) %% MY AXES LIMITS


grid minor;
Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

grid on; %% ENABLE GRID FOR BETTER VIEW


zoom on; %% ENABLE THE USER TO NAVIGATE ZOOM-IN and OUT

hold on; %% THIS IS TO HOLD OUR CURRENT FIGURE


%% DATA FOR OUR GRAPH

x8b=[-6 6]; %% X-AXIS ORIGIN


y8b=[0 0]; %% X-AXIS ORIGIN
x9b=[0 0]; %% Y-AXIS ORIGIN
y9b=[-4 4]; %% Y-AXIS ORIGIN

plot(x8b,y8b,x9b,y9b); %% DISPLAY X & Y AXES

hold off; %% STOP HOLD FOR ANY FUNCTION


%% END OF EVEN FUNCTION

% PLOT FOR OUR ODD SIGNAL USING THE FORMULA Xo(t) = 1/2 ( x(t) - x(-t) )

e1b=(1/2)*(x1a-x1b);
e2b=(1/2)*(x2a-x2b);
e3b=(1/2)*(x3a-x3b);
e4b=(1/2)*(x1b-x1a);
e5b=(1/2)*(x2b-x2a);
e6b=(1/2)*(x3b-x3a);

%% GRAPH FOR OUR ODD SIGNALS

subplot(3,1,3);

stem(xe1,e1b,'filled');
hold on;
stem(xe2,e2b,'MarkerFaceColor','black');
hold on;
stem(xe3,e3b,'MarkerFaceColor','green');
hold on;
stem(xe4,fliplr(e4b),'MarkerFaceColor','yellow');
hold on;
stem(xe5,fliplr(e5b),'MarkerFaceColor','magenta');
hold on;
stem(xe6,fliplr(e6b),'MarkerFaceColor','blue');

xlabel('n'); %% Label for X-Axis


ylabel('x[n]'); %% Label for Y-Axis
title ({'ACTIVITY #4','ODD -- DISCRETE-TIME SIGNAL'}); % DISPLAYS TITLE

axis([-3.5 3.5 -3.5 3.5]) %% MY AXES LIMITS


grid on; %% ENABLE GRID FOR BETTER VIEW
grid minor; %% GRID FOR BETTER ACCURACY READING
zoom on; %% ENABLE THE USER TO NAVIGATE ZOOM-IN and OUT

hold on; %% THIS IS TO HOLD OUR CURRENT FIGURE


%% DATA FOR OUR GRAP
Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

x8c=[-5.5 5.5]; %% X-AXIS ORIGIN


y8c=[0 0]; %% X-AXIS ORIGIN
x9c=[0 0]; %% Y-AXIS ORIGIN
y9c=[-4 4]; %% Y-AXIS ORIGIN

plot(x8c,y8c,x9c,y9c); %% DISPLAY X & Y AXES

hold off; %% STOP HOLD FOR ANY FUNCTION


%% END OF OUR GRAPH
FUNCTIONS
x1=-5:.25:-4; % MY RANGE FOR THE 1st FUNCTION
y1=-cos(((pi/6)*x1)+(pi/6)); % THE EQUATION OF MY 1st LIMIT

( ) + ( )

x2=-4:.25:-3; % MY RANGE FOR THE 2nd FUNCTION


y2=(-2*x2*1.25-12); % THE EQUATION OF MY 2nd LIMIT
c1=[-4:0.75:-4]; % CONSTANTS
t1=[-2:0.75:0]; % CONSTANTS
.
( )
Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

x3=-3:.30:0; % MY RANGE FOR THE 3rd FUNCTION


y3=x3*1.5; % MY EQUATION OF MY 3rd LIMIT
.

x4=0:.30:3; % MY RANGE FOR THE 4th FUNCTION


y4=sin((pi/2)*x4); % MY EQUATION OF MY 4th LIMIT
x5=[3 3]; % CONSTANTS
y5=[-1 -2]; % CONSTANTS

( )

Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

x6=[3:0.25:4]; % MY LIMITS FOR THE 5th FUNCTION


y6=[-2:0.25-2]; % x(t) = -2
x7=[4:0.25:4]; % CONSTANTS
y7=[-2:0.75:0]; % CONSTANTS
<

x10=4:.25:5; % MY FINAL LIMIT FOR THE 6th FUNCTION


y10=-cos(((pi/6)*x10)-(pi/6)); % MY LAST EQUATION

( ) ( ) <

Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

Discrete-Time Signal

Even Function of our Continuous-Time Signal


Name: Joevelle Zabate Baflor Instructor: Engr. Joseph Manbert Mendez, REcE
Subject: ECE415 (SPECTRA) Date: July 08, 2017

Odd Function of our Continuous-Time Signal

THE FINAL OUTPUT WAVEFORM

You might also like