clc;
clear;
close all;
n = -10:.5:10;
x = n.^2; % example signal — try changing this
x_reversed = fliplr(x); % this represents x(-t) since t is symmetric about 0
if isequal(x, x_reversed)
disp("The signal is EVEN");
elseif isequal(x, -x_reversed)
disp("The signal is ODD");
else
disp("The signal is NEITHER even nor odd");
end
x = sin(n) + cos(n);
reverse = fliplr(x);
even = (x + reverse)./2;% NOT periodic (decaying envelope)
odd = (x - reverse)./2;
subplot(2,1,1);
stem(n, even,"filled");
title("Even component");
xlabel("t"); ylabel("Amplitude");
grid on;
subplot(2,1,2);
stem(n, odd,"filled");
title("Odd component");
xlabel("t"); ylabel("Amplitude");
grid on;
To embed this project on your website, copy the following code and paste it into your website's HTML: