-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphasePlotAve.m
More file actions
68 lines (65 loc) · 2.51 KB
/
Copy pathphasePlotAve.m
File metadata and controls
68 lines (65 loc) · 2.51 KB
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
%% phasePlot(freq, phase, titleStr, xlabelStr, ylabelStr, yRange) plot
% a tuning curve of 'phase (cycle)' as a function of 'freq' with a title,
% xlabel, ylabel, and y axis range specified by the following paratmers
function phasePlot_3(freq, phase, nPol, titleStr, xlabelStr, ylabelStr, yRange, phaseSE)
fontSize=12; lineWidth=2.5; Logscale=1;
cmap=jet(3*8); cmap=cmap(end/3+1:-1:1,:);
% cmap=repmat([1 1 1],[8,1]); cmap=cmap.*repmat(linspace(0.8,0.2,8)',[1,3]);
if sum(sum(isfinite(phase)))~=0
for i=8:-1:1
if sum(isfinite(phase(:,i)))>0
phaseTemp=phase(isfinite(phase(:,i)),i);
freq2=freq(isfinite(phase(:,i)))/1e3;
% plot markers
if isempty(phaseSE)
plot(freq2,phaseTemp,'o','LineWidth',1,...
'MarkerEdgeColor',cmap(i,:),...
'MarkerSize',1,'Color',cmap(i,:)); hold on;
else
phaseSETemp=phaseSE(isfinite(phase(:,i)),i);
errorbar(freq2,phaseTemp,phaseSETemp,'o','color',cmap(i,:),...
'linewidth',1,'MarkerEdgeColor','none'); hold on;
end
end
end
for i=8:-1:1
if sum(isfinite(phase(:,i)))>0
if i<4
nPolAdj=nPol-1;
else
nPolAdj=nPol;
end
phaseTemp=phase(isfinite(phase(:,i)),i);
freq2=freq(isfinite(phase(:,i)))/1e3;
if nPolAdj>0
% plot fitted lines
coeff=polyfit((freq2),phaseTemp',nPolAdj);
freqPol=linspace(freq2(1),freq2(end),100);freqPol=(freqPol);
phasePol=zeros(size(freqPol));
for j=0:nPolAdj
phasePol=phasePol+coeff(nPolAdj-j+1)*freqPol.^j;
end
plot(freqPol,phasePol,'-','LineWidth',lineWidth,...
'Color',cmap(i,:)); hold on;
else
% plot the raw data
plot(freq2,phaseTemp,'-','LineWidth',lineWidth,...
'Color',cmap(i,:)); hold on;
end
end
end
hold off;
if isfinite(yRange)
axis([2 14 yRange]);
else
axis([2 14 -8 1]);
end
set(gca,'YScale','linear','fontsize',fontSize);
set(gca,'Xtick',2:2:12,'Ytick',-10:0.5:3);
if Logscale, set(gca,'XScale','log');
else set(gca,'XScale','linear');
end
title(titleStr); xlabel(xlabelStr); ylabel(ylabelStr);
pause(0.1);
end
end