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
|
function h=semiaudplot(x,y,varargin)
%-*- texinfo -*-
%@deftypefn {Function} semiaudplot
%@verbatim
%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.
%
%@end verbatim
%@strong{Url}: @url{http://ltfat.github.io/doc/auditory/semiaudplot.html}
%@seealso{freqtoaud}
%@end deftypefn
% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>.
% This file is part of LTFAT version 2.3.1
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
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;
|