-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTEST_PPS_1DSignal_04032015.m
122 lines (102 loc) · 3.19 KB
/
TEST_PPS_1DSignal_04032015.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
% Test program for computation periodic power spectrum (PPS) of 1D real number signal
%
% Changchuan Yin, Ph.D.
% Dept. of Mathematics, Statistics and Computer Science
% University of Illinois at Chicago
% Last update 02/08/2016
%
% Citation
% Yin, C., & Wang, J. (2016).Periodic power spectrum with applications in detection of latent periodicities
% in DNA sequences. Journal of Mathematical Biology.
clear
%======================================
% 1.Siangal and singal plotting
p1=20;
p2=50;
n=300;
t=1:n;
L=length(t);
theta=pi/4;
signal = sin(2*pi*(t/p1)+theta) + cos(2*pi*(t/p2)+theta)+ 2*randn(size(t)); % Good one
figure
fig1=plot(signal);
%-------------------------
set(fig1 , ...
'LineWidth' , 1.5 );
hXLabel = xlabel('Time (second)' );
hYLabel = ylabel('Signal' );
title('Periodic signal')
set([hXLabel, hYLabel] , ...
'FontName' , 'AvantGarde', ...
'FontSize' , 10, ...
'FontWeight' , 'bold');
set(gca, ...
'Box' , 'off' , ... %No rectangle cover the figure
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'on' , ...
'YMinorTick' , 'on' , ...
'YGrid' , 'off' , ...
'XColor' , [.3 .3 .3], ...
'LineWidth' , 1,...
'YColor' , [.3 .3 .3]);
%======================================
% 2.DFT plotting
FT_s=fft(signal);
PS_s=abs(FT_s).^2;
N=length(PS_s);
half=floor(N/2);
figure
PS_s(1)=0; %Ignore the constant, for plotting only
fig2=plot(PS_s(1:half));
%-------------------------
set(fig2 , ...
'LineWidth' , 1.5 );
my=max(PS_s(2:half))+500;
ylim([1,my])
hXLabel = xlabel('Frequency' );
hYLabel = ylabel('Fourier power spectrum' );
title('Fourier power spectrum of periodic signal');
set([hXLabel, hYLabel] , ...
'FontName' , 'AvantGarde', ...
'FontSize' , 10, ...
'FontWeight' , 'bold');
set(gca, ...
'Box' , 'off' , ... %No rectangle cover the figure
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'on' , ...
'YMinorTick' , 'on' , ...
'YGrid' , 'off' , ...
'XColor' , [.3 .3 .3], ...
'LineWidth' , 1,...
'YColor' , [.3 .3 .3]);
%======================================
% 3. PPS plotting
maxP=n;
vPPS=PPS(signal,maxP)
figure
vPPS(1)=0; %Ignore the constant, for plotting only
fig3=plot(vPPS(1:maxP));
set(fig3 , ...
'LineWidth' , 1.5 );
%mx=max(PPS(2:p))+500;
%ylim([1,mx])
%ylim([1,16])
hXLabel = xlabel('Periodicity' );
hYLabel = ylabel('Power spectrum' );
title('Power power spectrum of periodic signal');
set([hXLabel, hYLabel] , ...
'FontName' , 'AvantGarde', ...
'FontSize' , 10, ...
'FontWeight' , 'bold');
set(gca, ...
'Box' , 'off' , ... %No rectangle cover the figure
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'on' , ...
'YMinorTick' , 'on' , ...
'YGrid' , 'off' , ...
'XColor' , [.3 .3 .3], ...
'LineWidth' , 1,...
'YColor' , [.3 .3 .3]);