-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnspplotf3d_tres3_connLinear.m
100 lines (86 loc) · 2.37 KB
/
nspplotf3d_tres3_connLinear.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
function [plv,plph]=nspplotf3d_tres3_connLinear(ph, phr, tres, half_winsize, S)
% Input-
% fm - 2-D matrix that specifies the frequency values
% FM - 3-D matrix that specifies the frequency values of envelope
% PH - 3-D matrix that specifies the phases of envelope
% tres - the time resolution
% Output-
% All_nt - 4-D matrix of the HHS spectrum, where
% 1st dimension specifies the number of frequencies,
% 2nd dimension specifies the number of frequencies of envelope
% 3rd dimension specifies the number of time points
% 4th dimension what number IMF
% fscale - vector that specifies the frequency-axis values
% Fscale - vector that specifies the AM frequency-axis values
%----- Check the input arguments
if nargin<3
error('nspplot: both frequency and amplitude matrices required');
end
%----- Specify default variables
% if nargin < 5
% ntp0 = [];
% ntp1 = [];
% end
if nargin<3
tres=[];
end
if nargin<4
half_winsize=[];
end
if nargin<5
S=[];
end
[npt,nimf]=size(ph);
%----- Initialize default variables
% if isempty(ntp0)
% ntp0=1;
% ntp1=npt;
% end
if isempty(tres)
tres=ceil(npt/25);
end
if isempty(half_winsize)
half_winsize=150;
end
%winsize=2*half_winsize+1;
t=ceil((1:npt)*tres/npt); %t is the mapping position of time values into the time axis grid
[~,firstid]=unique(t);
intv=round(mean(diff(firstid)));
if mod(intv,2)==1
dist_to_med=round(0.5*(intv-1));
else
dist_to_med=round(0.5*intv);
end
medid=(firstid+dist_to_med)';
%All_nt=zeros(tres,1);
%for i_imf = 1:nimf
%nt=zeros(fres,Freq);
% f = fm(:,1);
p = ph(:,1);
% fr = fmr(:,1);
pr = phr(:,1);
% medf=median(f);
% medF=median(F);
% [~,amid]=min(abs(medF-medf));
%F_am=F(:,amid);
% P_am=P(:,amid);
ph_diff=pr-p;
plv_vec= zeros(1,length(medid));
plv_vec=complex(plv_vec);
for ires= 1:length(medid)
if (medid(ires)- half_winsize)>=1
ph_initid=medid(ires)- half_winsize;
else
ph_initid=1;
end
if (medid(ires)+ half_winsize)<=npt
ph_endid=medid(ires)+ half_winsize;
else
ph_endid=npt;
end
ph_series=ph_diff(ph_initid:ph_endid);
ph_vecs = exp(sqrt(-1)*ph_series);
plv_vec(ires)=mean(ph_vecs);
end
plv=abs(plv_vec);
plph=angle(plv_vec);