[e6709d]: auditory / semiaudplot.m Maximize Restore History

Download this file

semiaudplot.m    64 lines (52 with data), 1.8 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
function h=semiaudplot(x,y,varargin)
%SEMIAUDPLOT 2D plot on auditory scale
% Usage: h=semiaudplot(x,y);
%
% `semiaudplot(x,y)` plots the data $(x,y)$ on an auditory scale. By
% default the values of the x-axis will be shown on the Erb-scale.
%
% `semiaudplot` takes the following parameters at the end of the line of input
% arguments:
%
% 'x' Make the x-axis use the auditory scale. This is the default.
%
% 'y' Make the y-axis use the auditory scale.
%
% 'opts',c Pass options stored in a cell array onto the plot
% function.
%
% In addition to these parameters, the auditory scale can be
% specified. All scales supported by |freqtoaud| are supported. The default
% is to use the erb-scale.
%
% See also: freqtoaud
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
definput.import = {'ltfattranslate','freqtoaud'};
definput.flags.plotdir= {'x','y'};
definput.keyvals.tick = [0,100,250,500,1000,2000,4000,8000,16000];
definput.keyvals.res = 500;
definput.keyvals.opts = {};
[flags,kv]=ltfatarghelper({},definput,varargin);
n=500;
tickpos=freqtoaud(kv.tick,flags.audscale);
if flags.do_x
xmin=min(x);
xmax=max(x);
audminmax=freqtoaud([xmin,xmax],flags.audscale);
plotval=spline(x,y,audspace(xmin,xmax,n,flags.audscale));
plot(linspace(audminmax(1),audminmax(2),n),plotval,kv.opts{:});
set(gca,'XTick',tickpos);
set(gca,'XTickLabel',num2str(kv.tick(:)));
xlabel(sprintf('%s (Hz)',kv.frequency));
end;
if flags.do_y
ymin=min(y);
ymax=max(y);
audminmax=freqtoaud([ymin,ymax],flags.audscale);
plot(x,freqtoerb(y),kv.opts{:});
set(gca,'YTick',tickpos);
set(gca,'YTickLabel',num2str(tick(:)));
ylabel(sprintf('%s (Hz)',kv.frequency));
end;