1. 程式人生 > >將一個序列分解成奇偶序列的組合

將一個序列分解成奇偶序列的組合

clc
clear all
close all


%% original sequence
t = -10:1:10;
hn1 = cos(2*pi*0.1*t);
hnf1 = fliplr(hn1);

hn2 = sin(2*pi*0.1*t);
hnf2 = fliplr(hn2);

hn3 = (hn1 + hn2)/2;
hnf3 = fliplr(hn3);

%% even sequence
he1 = 1/2*(hn1 + hnf1);
he2 = 1/2*(hn2 + hnf2);
he3 = 1/2*(hn3 + hnf3);

%% odd sequence
ho1 = 1/2*(hn1 - hnf1);
ho2 = 1/2*(hn2 - hnf2);
ho3 = 1/2*(hn3 - hnf3);

%% figure plot
figure('Name','y軸對稱序列','NumberTitle','off')
subplot(3,1,1)
stem(t,hn1)
title('原始序列')
subplot(3,1,2)
stem(t,he1)
title('分解出偶序列')
subplot(3,1,3)
stem(t,ho1)
title('分解出奇序列')

figure('Name','原點對稱序列','NumberTitle','off')
subplot(3,1,1)
stem(t,hn2)
title('原始序列')
subplot(3,1,2)
stem(t,he2)
title('分解出偶序列')
subplot(3,1,3)
stem(t,ho2)
title('分解出奇序列')

figure('Name','非對稱序列','NumberTitle','off')
subplot(3,1,1)
stem(t,hn3)
title('原始序列')
subplot(3,1,2)
stem(t,he3)
title('分解出偶序列')
subplot(3,1,3)
stem(t,ho3)
title('分解出奇序列')