⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 afdopen.m

📁 AFD - Advanced Filter Design using MATLABMiroslav D. Lutovac, Dejan V. Tosicversion 1.00 released 15
💻 M
字号:
function [speck,speca,filnumb,filtype,nmin,nmax,nincmin,nincmax] = ...
         afdopen(moreaxis)

% afdopen.m  AFD open specification
% 1:15  3/2/99
%
%   Authors: Dejan V. Tosic, Miroslav D. Lutovac, 1999.02.08
%                 tosic@telekom.etf.bg.ac.yu
%                 lutovac@galeb.etf.bg.ac.yu
%
%   Copyright (c) 1999 by Tosic & Lutovac
%   $Revision: 1.0 $  $Date: 1999/02/08 03:07:42 $
%
%   References:
%        Miroslav D. Lutovac, Dejan V. Tosic, Brian L. Evans
%           Advanced Filter Design for Signal Processing
%                   Using MATLAB and Mathematica

%% calls:
%% afda2k.m, afdorder.m

[filename, pathname] = uigetfile('*.dat', 'Open Specification File');
filespec = [pathname, filename];
if filename==0
 return
end
eval(['load ', filespec]);
dotposit = findstr(filename,'.');
eval(['speca =', filename(1:dotposit-1), ';']);
speclen = length(speca);

if speclen==4
 filnumb = 1;
elseif speclen>4
 filnumb = speca(1);
 speca = speca(2:speclen);
else
 error('AFD ERROR in filter specification: Insufficient data.')
end

if any(speca-abs(speca))
 error('AFD ERROR in filter specification: Negative data.')
end

speck = speca;

delete(gca);
if moreaxis
 delete(gca);
end
axis off;

if     filnumb==1
 filtype = 'l';
 text(0,1.0, 'Attenuation limits lowpass specification from');
 text(0,0.94, [lower(pathname),filename], 'FontWeight', 'bold');
 text(0,0.8, ['Fpass = ', num2str(speca(1)), ' Hz']);
 text(0,0.7, ['Fstop = ', num2str(speca(2)), ' Hz']);
 text(0,0.6, ['Apass = ', num2str(speca(3)), ' dB']);
 text(0,0.5, ['Astop = ', num2str(speca(4)), ' dB']);
 text(0,0.4, 'Fpass = passband edge frequency in Hz');
 text(0,0.3, 'Fstop = stopband edge frequency in Hz')
 text(0,0.2, 'Apass = maximum passband attenuation in dB')
 text(0,0.1, 'Astop = minimum stopband attenuation in dB')
 if speca(1)>=speca(2)
  error('AFD ERROR in lowpass spec: Fpass >= Fstop.')
 end
 if speca(3)>=speca(4)
  error('AFD ERROR in lowpass spec: Apass >= Astop.')
 end
 speck(3:4) = afda2k(speca(3:4));
 [nmin,nmax,nincmin,nincmax] = afdorder(speck,filnumb);

elseif filnumb==2
 filtype = 'h';
 text(0,1.0, 'Attenuation limits highpass specification from');
 text(0,0.94, [lower(pathname),filename], 'FontWeight', 'bold');
 text(0,0.8, ['Fstop = ', num2str(speca(1)), ' Hz']);
 text(0,0.7, ['Fpass = ', num2str(speca(2)), ' Hz']);
 text(0,0.6, ['Apass = ', num2str(speca(3)), ' dB']);
 text(0,0.5, ['Astop = ', num2str(speca(4)), ' dB']);
 text(0,0.4, 'Fpass = passband edge frequency in Hz');
 text(0,0.3, 'Fstop = stopband edge frequency in Hz')
 text(0,0.2, 'Apass = maximum passband attenuation in dB')
 text(0,0.1, 'Astop = minimum stopband attenuation in dB')
 if speca(1)>=speca(2)
  error('AFD ERROR in highpass spec: Fstop >= Fpass.')
 end
 if speca(3)>=speca(4)
  error('AFD ERROR in highpass spec: Apass >= Astop.')
 end
 speck(3:4) = afda2k(speca(3:4));
 [nmin,nmax,nincmin,nincmax] = afdorder(speck,filnumb);

elseif filnumb==3
 filtype = 'b';
 text(0,1.0, 'Attenuation limits bandpass specification from');
 text(0,0.94, [lower(pathname),filename], 'FontWeight', 'bold');
 text(0,0.8,  ['Fstop1 = ', num2str(speca(1)), ' Hz']);
 text(0,0.74, ['Fpass1 = ', num2str(speca(2)), ' Hz']);
 text(0,0.68, ['Fpass2 = ', num2str(speca(3)), ' Hz']);
 text(0,0.62, ['Fstop2 = ', num2str(speca(4)), ' Hz']);
 text(0,0.56, ['Astop1 = ', num2str(speca(5)), ' dB']);
 text(0,0.50, ['Apass = ',  num2str(speca(6)), ' dB']);
 text(0,0.44, ['Astop2 = ', num2str(speca(7)), ' dB']);
 text(0,0.28, 'Fpass = passband edge frequency in Hz');
 text(0,0.22, 'Fstop = stopband edge frequency in Hz')
 text(0,0.16, 'Apass = maximum passband attenuation in dB')
 text(0,0.1, 'Astop = minimum stopband attenuation in dB')
 if speca(1)>=speca(2)
  error('AFD ERROR in bandpass spec: Fstop1 >= Fpass1.')
 end
 if speca(2)>=speca(3)
  error('AFD ERROR in bandpass spec: Fpass1 >= Fpass2.')
 end
 if speca(3)>=speca(4)
  error('AFD ERROR in bandpass spec: Fpass2 >= Fstop2.')
 end
 if speca(6)>=speca(5)
  error('AFD ERROR in bandpass spec: Apass >= Astop1.')
 end
 if speca(6)>=speca(7)
  error('AFD ERROR in bandpass spec: Apass >= Astop2.')
 end
 speck(5:7) = afda2k(speca(5:7));
 [nmin,nmax,nincmin,nincmax] = afdorder(speck,filnumb);

elseif filnumb==4
 filtype = 'r';
 text(0,1.0, 'Attenuation limits bandreject specification from');
 text(0,0.94, [lower(pathname),filename], 'FontWeight', 'bold');
 text(0,0.8,  ['Fpass1 = ', num2str(speca(1)), ' Hz']);
 text(0,0.74, ['Fstop1 = ', num2str(speca(2)), ' Hz']);
 text(0,0.68, ['Fstop2 = ', num2str(speca(3)), ' Hz']);
 text(0,0.62, ['Fpass2 = ', num2str(speca(4)), ' Hz']);
 text(0,0.56, ['Apass1 = ', num2str(speca(5)), ' dB']);
 text(0,0.50, ['Astop = ',  num2str(speca(6)), ' dB']);
 text(0,0.44, ['Apass2 = ', num2str(speca(7)), ' dB']);
 text(0,0.28, 'Fpass = passband edge frequency in Hz');
 text(0,0.22, 'Fstop = stopband edge frequency in Hz')
 text(0,0.16, 'Apass = maximum passband attenuation in dB')
 text(0,0.1, 'Astop = minimum stopband attenuation in dB')
 if speca(1)>=speca(2)
  error('AFD ERROR in bandreject spec: Fpass1 >= Fstop1.')
 end
 if speca(2)>=speca(3)
  error('AFD ERROR in bandreject spec: Fstop1 >= Fstop2.')
 end
 if speca(3)>=speca(4)
  error('AFD ERROR in bandreject spec: Fstop2 >= Fpass2.')
 end
 if speca(5)>=speca(6)
  error('AFD ERROR in bandreject spec: Apass1 >= Astop.')
 end
 if speca(7)>=speca(6)
  error('AFD ERROR in bandreject spec: Apass2 >= Astop.')
 end
 speck(5:7) = afda2k(speca(5:7));
 [nmin,nmax,nincmin,nincmax] = afdorder(speck,filnumb);

else
 error(['AFD ERROR: Unsupported filter type ', num2str(filnumb), '.'])

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -