Code covered by the BSD License  

Highlights from
Analog Filter Design Toolbox

image thumbnail
from Analog Filter Design Toolbox by James Squire
GUI to design and simulate active (opamp) LP and HP Bessel, Butter, Cheby, and Elliptic filters.

SpecifyFilter_SaveStrFilterObject(handles)
function SpecifyFilter_SaveStrFilterObject(handles)
% SpecifyFilter_SaveStrFilterObject is a subfile of the AnalogFilter GUI collection
%
% James C. Squire, 2002
% Assistant Professor, Virginia Military Institute
% ver 1.0

% SpecifyFilter_SaveStrFilterObject takes data from the SpecifyFilter GUI and stores it 
% in the global variable strFilterObject


global strFilterObject

vsPurpose = get(handles.uipmPurpose,'String');
iPurpose = get(handles.uipmPurpose,'Value');
strFilterObject.sPurpose = vsPurpose{iPurpose};

vsType = get(handles.uipmType,'String');
iType = get(handles.uipmType,'Value');
strFilterObject.sType = vsType{iType};

strFilterObject.nOrder = get(handles.uipmOrder,'Value');
strFilterObject.fFc = str2num(get(handles.uitxFc,'String'))*10^((get(handles.uipmFcUnits,'Value')-2)*3);
strFilterObject.fGp = str2num(get(handles.uitxGp,'String'));
strFilterObject.fGs = str2num(get(handles.uitxGs,'String'));
strFilterObject.fGain = str2num(get(handles.uitxGain,'String'));

% create the sTitle
iUnits = get(handles.uipmFcUnits,'Value');
vsUnits = get(handles.uipmFcUnits,'String');
switch strFilterObject.nOrder
    case 1, sTemp='st';
    case 2, sTemp='nd';
    case 3, sTemp='rd';
    otherwise, sTemp='th';
end
sTitle = sprintf('%sP %g%s order %s: fc = %s%s', ...
    strFilterObject.sPurpose(1),strFilterObject.nOrder, sTemp, strFilterObject.sType, ...
    get(handles.uitxFc,'String'),vsUnits{iUnits} );
switch strFilterObject.sType
    case {'Bessel','Butterworth'}
    case 'Chebychev I'
        sTitle = sprintf('%s, Gp = %g',sTitle,strFilterObject.fGp);
    case 'Chebychev II'
        sTitle = sprintf('%s, Gs = %g',sTitle,strFilterObject.fGs);
    case 'Elliptic'
        sTitle = sprintf('%s, Gp = %g, Gs = %g',sTitle,strFilterObject.fGp,strFilterObject.fGs);
    otherwise
        error(['In ' mfilename ' unrecognized type ' strFilterObject.sType])
end        
strFilterObject.sTitle = sTitle;

Contact us at files@mathworks.com