-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelperCWTTimeFreqPlot.m
90 lines (74 loc) · 2.63 KB
/
helperCWTTimeFreqPlot.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
function helperCWTTimeFreqPlot(cfs,time,freq,PlotType,varargin)
% This function helperCWTTimeFreqPlot is only in support of
% CWTTimeFrequencyExample and PhysiologicSignalAnalysisExample.
% It may change in a future release.
params = parseinputs(varargin{:});
if strncmpi(PlotType,'surf',1)
args = {time,freq,abs(cfs).^2};
surf(args{:},'edgecolor','none');
view(0,90);
axis tight;
shading interp; colormap(parula(128));
% h = colorbar;
% h.Label.String = 'Power';
% h.Location='southoutside';
% colorbar('southoutside')
if isempty(params.xlab) && isempty(params.ylab)
xlabel('Time'); ylabel('Hz');
else
xlabel(params.xlab); ylabel(params.ylab);
end
elseif strcmpi(PlotType,'contour')
contour(time,freq,abs(cfs).^2);
grid on; colormap(parula(128));
h = colorbar;
h.Label.String = 'Power';
if isempty(params.xlab) && isempty(params.ylab)
xlabel('Time'); ylabel('Hz');
else
xlabel(params.xlab); ylabel(params.ylab);
end
elseif strcmpi(PlotType,'contourf')
contourf(time,freq,abs(cfs).^2);
grid on; colormap(parula(128));
h = colorbar;
h.Label.String = 'Power';
h.Location='southoutside';
if isempty(params.xlab) && isempty(params.ylab)
xlabel('Time'); ylabel('Hz');
else
xlabel(params.xlab); ylabel(params.ylab);
end
elseif strncmpi(PlotType,'image',1)
imagesc(time,freq,abs(cfs).^2);
colormap(parula(128));
AX = gca;
h = colorbar;
h.Label.String = 'Power';
if isempty(params.xlab) && isempty(params.ylab)
xlabel('Time'); ylabel('Hz');
else
xlabel(params.xlab); ylabel(params.ylab);
end
end
if ~isempty(params.PlotTitle)
title(params.PlotTitle);
end
%----------------------------------------------------------------
function params = parseinputs(varargin)
params.PlotTitle = [];
params.xlab = [];
params.ylab = [];
params.threshold = -Inf;
if isempty(varargin)
return;
end
Len = length(varargin);
if (Len==1)
params.PlotTitle = varargin{1};
end
if (Len == 3)
params.PlotTitle = varargin{1};
params.xlab = varargin{2};
params.ylab = varargin{3};
end