# Finding the even and odd parts of signal/sequence and real and imaginary parts of signal

Aim:  Program for finding even and odd parts of signals Using MATLAB Software.

Equipments:

PC with windows (95/98/XP/NT/2000).

MATLAB Software.

1. Even and odd parts of signal program:

``````close all;
clear all;
t=0:.005:4*pi;
x=sin(t)+cos(t); % x(t)=sint(t)+cos(t)
subplot(2,2,1)
plot(t,x)
xlabel('t');
ylabel('amplitude')
title('input signal')
y=sin(-t)+cos(-t) % y=x(-t)
subplot(2,2,2)
plot(t,y)
xlabel('t');
ylabel('amplitude')
title('input signal with t=-t')
z=x+y
subplot(2,2,3)
plot(t,z/2)
xlabel('t');
ylabel('amplitude')
title('even part of the signal')
p=x-y
subplot(2,2,4)
plot(t,p/2)
xlabel('t');
ylabel('amplitude')
title('odd part of the signal') ``````

2. Even and odd parts of signal program:

%finding Odd and even parts of a signal

``````clc
clear all
close all
f=input('enter frequency')
T=1/f;
t=0:T/f:T
x=sin(2*pi*f*t)
t1=-fliplr(t)
t1(length(t1))=[]
t2=[t1 t]
x1=zeros(1,length(t2))
i=find(t2==min(t))
x1(i:length(x1))=x
y=fliplr(x1)
xe=(x1+y)*0.5
xo=(x1-y)*0.5
subplot(2,2,1)
plot(t,x)
title('input sequence')
xlabel('time')
ylabel('amplitude')
subplot(2,2,2)
plot(t2,xo)
title('odd part of sequence')
xlabel('time')
ylabel('amplitude')
subplot(2,2,3)
plot(t2,xe)
title('even part of sequence')
xlabel('time')
ylabel('amplitude')``````

Output:

1.Even and odd parts of sequence program:

``````t=-4:1:4;
h=[ 2 1 1 2 0 1 2 2 3 ];
subplot(3,2,1)
stem(t,h);
xlabel('time'); ylabel('amplitude');
title('signal');
n=9;
for i=1:9
x1(i)=h(n);
n=n-1;
end
subplot(3,2,2)
stem(t,x1);
xlabel('time'); ylabel('amplitude');
title('folded signal');
z=h+x1
subplot(3,2,3);
stem(t,z);
xlabel('time'); ylabel('amplitude');
title('sum of two signal');
subplot(3,2,4);
stem(t,z/2);
xlabel('time'); ylabel('amplitude');
title('even signal');
a=h-x1;
subplot(3,2,5);
stem(t,a);
xlabel('time'); ylabel('amplitude');
title('difference of two signal');
subplot(3,2,6);
stem(t,a/2);
xlabel('time'); ylabel('amplitude');
title('odd signal');``````

2.Even and odd parts of sequence program:

``````clc
clear all
close all
x=[1 2 3]
n=[0 1 3]
n1=-fliplr(n)
n1(length(n1))=[]
n2=[n1 n]
x1=zeros(1,length(n2))
i=find(n2==min(n))
x1(i:length(x1))=x
y=fliplr(x1)
xe=(x1+y)*0.5
xo=(x1-y)*0.5
subplot(2,2,1)
stem(n,x)
title('input sequence')
xlabel('time')
ylabel('amplitude')
subplot(2,2,2)
stem(n2,xo)
title('odd part of sequence')
xlabel('time')
ylabel('amplitude')
subplot(2,2,3)
stem(n2,xe)
title('even part of sequence')
xlabel('time')
ylabel('amplitude')``````

Output:

ENERGY AND POWER SIGNAL:  A signal can be categorized into energy signal or power signal:

Energy signal has a finite energy, 0 < E < 8. And Power=0

Energy signals have values only in the limited time duration.

Example: A signal having only one square pulse is energy signal.

A signal that decays exponentially has finite energy

Energy of Continuous Signals

Energy of Discrete Signals

Power signal has a finite energy, 0 < P < 8. And Energy =8

Example: sine

Power of Continuous Signals

Power of Discrete Signals

% Program to find the energy of signal

``````clc;
close all;
clear all;
x=[1,2,3];
n=3
e=0;
for i=1:n;
e=e+(x(i).*x(i));
end``````

% Program to find the energy of signal

``````clc;
close all;
clear all;
N=2
x=ones(1,N)
for i=1:N
y(i)=(1/3)^i.*x(i);
end
n=N;
e=0;
for i=1:n;
e=e+(y(i).*y(i));
end``````

% Program to find the power of signal

``````clc;
close all;
clear all;
N=2
x=ones(1,N)
for i=1:N
y(i)=(1/3)^i.*x(i);
end
n=N;
e=0;
for i=1:n;
e=e+(y(i).*y(i));
end
p=e/(2*N+1);``````

% Program to find the power of signal

``````N=input('type a value for N');
t=-N:0.0001:N;
x=cos(2*pi*50*t).^2;
disp('the calculated power p of the signal is');
P=sum(abs(x).^2)/length(x)
plot(t,x);
axis([0 0.1 0 1]);
disp('the theoretical power of the signal is');``````

Output:  P_theory=3/8

Result:

The even and odd parts of signal/sequence and real and imaginary part of signals are calculated and plotted.

• Created
Dec 02, 2019
• Updated
Mar 01, 2020
• Views
865
You May Like