Code covered by the BSD License
-
GuiBuildActiveCircuit(varargi...
GUIBUILDACTIVECIRCUIT M-file for GuiBuildActiveCircuit.fig
-
GuiBuildStageInformation(vara...
GUIBUILDSTAGEINFORMATION M-file for guiBuildStageInformation.fig
-
GuiFilterOrder(varargin)
GUIFILTERORDER M-file for guiFilterOrder.fig
-
GuiListFrequencyResponse(vara...
GUILISTFREQUENCYRESPONSE M-file for GuiListFrequencyResponse.fig
-
GuiListTransferFunction(varar...
GUILISTTRANSFERFUNCTION M-file for guiListTransferFunction.fig
-
GuiPlotFrequencyResponse(vara...
GUIPLOTFREQUENCYRESPONSE M-file for GuiPlotFrequencyResponse.fig
-
GuiPlotUserData(varargin)
GUIPLOTUSERDATA M-file for GuiPlotUserData.fig
-
GuiSpecifyFilter(varargin)
GUISPECIFYFILTER M-file for GuiSpecifyFilter.fig
-
GuiTimeResponse(varargin)
GUITIMERESPONSE M-file for GuiTimeResponse.fig
-
BuildCircuit_FindZ1P1K1(curSt...
BuildCircuit_FindZ1P1K1 is a subfile of the AnalogFilter GUI collection
-
BuildCircuit_LastStage(strCir...
BuildCircuit_LastStage is a subfile of the AnalogFilter GUI collection
-
BuildCircuit_SelectCircuit(st...
BuildCircuit_SelectCircuit is a subfile of the AnalogFilter GUI collection
-
BuildCircuit_StageInformation...
BuildCircuit_StageInformation is a subfile of the AnalogFilter GUI collection
-
BuildCircuit_UpdateComponents...
BuildCircuit_UpdateComponents is a subfile of the AnalogFilter GUI collection
-
BuildCircuit_Zpk2Circuit(strF...
Zpk2Circuit is a subfile of the AnalogFilter GUI collection
-
FilterOrder_HelpContext
FilterOrder_HelpContext is a subfile of the AnalogFilter GUI collection
-
MenuAnalyzePoleZeroPlot
MenuAnalyzePoleZeroPlot is a subfile of the AnalogFilter GUI collection
-
MenuFileNew(handles)
MenuFileNew is a subfile of the AnalogFilter GUI collection
-
MenuFileOpen
MenuFileOpen is a subfile of the AnalogFilter GUI collection
-
MenuFileSave(handles)
MenuFileSave is a subfile of the AnalogFilter GUI collection
-
MenuFileSaveAs(handles)
MenuFileSaveAs is a subfile of the AnalogFilter GUI collection
-
MenuHelpAbout
MenuHelpAbout is a subfile of the AnalogFilter GUI collection
-
SpecifyFilter_HelpContext
SpecifyFilter_HelpContext is a subfile of the AnalogFilter GUI collection
-
SpecifyFilter_LoadPicture(han...
SpecifyFilter_LoadPicture is a subfile of the AnalogFilter GUI collection
-
SpecifyFilter_LoadStrFilterOb...
SpecifyFilter_LoadStrFilterObject is a subfile of the AnalogFilter GUI collection
-
SpecifyFilter_SaveStrFilterOb...
SpecifyFilter_SaveStrFilterObject is a subfile of the AnalogFilter GUI collection
-
SpecifyFilter_uipmType(handle...
SpecifyFilter_uipmType is a subfile of the AnalogFilter GUI collection
-
Utility_CalculateTime(z,p,k,t...
Utility_CalculateTime is a subfile of the AnalogFilter GUI collection
-
Utility_EngOutput(num, arg1,a...
Utility_EngOutput is a subfile of the AnalogFilter GUI collection
-
Utility_GetDefaultFilterObjec...
Utility_GetDefaultFilterObject is a subfile of the AnalogFilter GUI collection
-
Utility_Round2Tolerance(in,nT...
Utility_Round2Tolerance is a subfile of the AnalogFilter GUI collection
-
[a,b,c,d]=Utility_zpk2ss(z,p,...
Utility_zpk2ss is a subfile of the AnalogFilter GUI collection
-
strFilterObject=Utility_zpk(s...
Utility_zpk is a subfile of the AnalogFilter GUI collection
-
afd.m
-
View all files
from
Analog Filter Design Toolbox
by James Squire
GUI to design and simulate active (opamp) LP and HP Bessel, Butter, Cheby, and Elliptic filters.
|
| Utility_Round2Tolerance(in,nTol)
|
function out = Utility_Round2Tolerance(in,nTol)
% Utility_Round2Tolerance is a subfile of the AnalogFilter GUI collection
%
% Utility_Round2Tolerance(in,nTol) takes the number "in" and a tolerance nTol
% nTol may be 0, 1, 5, 10, 20, meaning closest standard 1%, etc.
% James C. Squire, Assistant Professor, Virginia Military Institute
% ver 1.0
if isempty(in)
out=[];
return
end
if in==0
out=0;
return
end
k=1;
if in<0
in=abs(in);
k=-1;
end
switch nTol
case 0
out=in;
return
case 1
vTol = [1 1.02 1.05 1.07 1.1 1.13 1.15 1.18 1.21 1.24 1.27 1.3 1.33 1.37 1.4 1.43 1.47 1.5 1.54 1.58 1.62 1.65 1.69 1.74 1.78 1.82 1.87 1.91 1.96 2 2.05 2.1 2.15 2.21 2.26 2.32 2.37 2.43 2.49 2.55 2.61 2.67 2.74 2.8 2.87 2.94 3.01 3.09 3.16 3.24 3.32 3.4 3.48 3.57 3.65 3.74 3.83 3.92 4.02 4.12 4.22 4.32 4.42 4.53 4.64 4.75 4.87 4.99 5.11 5.23 5.36 5.49 5.62 5.76 5.9 6.04 6.19 6.34 6.49 6.65 6.81 6.98 7.15 7.32 7.5 7.68 7.87 8.06 8.25 8.45 8.66 8.87 9.09 9.31 9.53 9.76 10];
case 5
vTol = [1 1.1 1.2 1.3 1.5 1.6 1.8 2.0 2.2 2.4 2.7 3.0 3.3 3.6 3.9 4.3 4.7 5.1 5.6 6.2 6.8 7.5 8.2 9.1 10];
case 10
vTol = [1 1.2 1.5 1.8 2.2 2.7 3.3 3.9 4.7 5.6 6.8 8.2 10];
case 20
vTol = [1 2.2 4.7 10];
otherwise
error('Unexpected argument in Round2Tolerance')
end
exponent = floor(log10(in));
mantissa = in/10^exponent;
[dummy, index] = min(abs(vTol - mantissa));
out = vTol(index)*10^exponent*k;
|
|
Contact us at files@mathworks.com