-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsep.m
153 lines (123 loc) · 2.67 KB
/
sep.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
% [nu nd]= sep(w,fs,t);
%
% this function
%
% [INPUTS]
% w: CWT coefficients.
% fs: frequency vector.
% t: time vector.
%
% [OUTPUTS]
% nu:
% nd:
% -------------------------------------------------------------------------
% By Mostafa Mousavi, [email protected]
% Last modify: Oct 2, 2016
% -------------------------------------------------------------------------
function [nu nd]= sep(w,fs,t)
[na n]=size(w);col=0;
for i = 1:n
col = col+abs(w(:,i));
end
xsmooth = smooth(col,0.05,'loess');
msmooth = xsmooth - 1.5*mean(xsmooth);
msmooth(msmooth<0) = 0;
nu = []; nd = [];
for i =2:length(msmooth)-1;
if (msmooth(i-1) == 0 & msmooth(i+1) > 0 & msmooth(i) == 0);
nu = [nu i+1];
end
if (msmooth(i-1) > 0 & msmooth(i+1) == 0 & msmooth(i) == 0);
nd = [nd i+1];
end
end
figure
subplot 121
hold on
a = 1:length(col);
a = a';
bar(a,col);
xlim([0 length(col)]);
% title({'Stacked';'Coefficients'});
% ylabel({'Magnitude'});
hold on
yrange=get(gca,'ylim');
for i = 1:length(nu);
h = line([nu(i),nu(i)],yrange);
set(h,'Color','magenta','LineWidth',1.5);
h = line([nd(i),nd(i)],yrange);
set(h,'Color','magenta','LineWidth',1.5);
end
hold off
ax = gca;
ax.XTick = [];
ax.TitleFontSizeMultiplier = 1.1;
ax.LabelFontSizeMultiplier=1.1;
ax.FontWeight='bold';
ax.Position=[0.15 0.40 0.100 0.300];
ax.View=[270 90]
hold off
clear title xlabel ylabel
subplot 122
hold on
tplot(w, t, fs);
% title('SS-CWT of Noise ');
% xlabel('Time (S)');
% ylabel('Frequency (Hz)');
ax = gca;
ax.YTick = [];
ax.Position=[0.265 0.40 0.600 0.300];
% ax.YAxisLocation = 'right';
ax.CLim=[-50 480];
ax.FontSize=12;
ax.TitleFontSizeMultiplier = 1.3;
ax.LabelFontSizeMultiplier=1.1;
ax.FontWeight='bold';
hold off
% figure
% hold on
% a = 1:length(col);
% a = a';
% bar(a,col);
% xlim([0 length(col)]);
% % title({'Stacked';'Coefficients'});
% % ylabel({'Magnitude'});
%
% hold on
% yrange=get(gca,'ylim');
%
% for i = 1:length(nu);
%
% h = line([nu(i),nu(i)],yrange);
% set(h,'Color','magenta','LineWidth',1.5);
%
% h = line([nd(i),nd(i)],yrange);
% set(h,'Color','magenta','LineWidth',1.5);
%
% end
% hold off
%
% ax = gca;
% ax.XTick = [];
% ax.TitleFontSizeMultiplier = 1.1;
% ax.LabelFontSizeMultiplier=1.1;
% ax.FontWeight='bold';
% % ax.Position=[0.15 0.40 0.100 0.300];
% % ax.View=[270 90]
% hold off
% clear title xlabel ylabel
%
%
% figure
% hold on
% tplot(w, t, fs);
% ax = gca;
% ax.YTick = [];
% % ax.Position=[0.265 0.40 0.600 0.300];
% % ax.YAxisLocation = 'right';
% ax.CLim=[-20 150];
% ax.FontSize=12;
% ax.TitleFontSizeMultiplier = 1.3;
% ax.LabelFontSizeMultiplier=1.1;
% ax.FontWeight='bold';
% hold off