Code covered by the BSD License  

Highlights from
Analog Filter Design Toolbox

image thumbnail

Analog Filter Design Toolbox

by

 

27 Dec 2005 (Updated )

GUI to design and simulate active (opamp) LP and HP Bessel, Butter, Cheby, and Elliptic filters.

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

% SpecifyFilter_LoadPicture loads an image into GuiSpecifyFilter's axis

% load FilterIcons.mat
persistent FilterPictures
if isempty(FilterPictures)   % load the compressed picture matrix
    t=load('FilterPictures.mat');
    FilterPictures = t.strGraphic;
end

% determine the current filter purpose, type, and order
vsPurpose = get(handles.uipmPurpose,'String');
iPurpose = get(handles.uipmPurpose,'Value');
sPurpose = vsPurpose{iPurpose};

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

nOrder = get(handles.uipmOrder,'Value');

% choose the current image and colormap
switch sType
    case 'Bessel'
        switch sPurpose
            case 'Lowpass'
                curImage = FilterPictures.LPBE.x;
                curCMap  = FilterPictures.LPBE.map;
            case 'Highpass'
                curImage = FilterPictures.HPBE.x;
                curCMap  = FilterPictures.HPBE.map;
            otherwise
                error(['Bad purpose of Bessel filter in ' mfilename])
        end
    case 'Butterworth'
        switch sPurpose
            case 'Lowpass'
                curImage = FilterPictures.LPBU.x;
                curCMap  = FilterPictures.LPBU.map;
            case 'Highpass'
                curImage = FilterPictures.HPBU.x;
                curCMap  = FilterPictures.HPBU.map;
            otherwise
                error(['Bad purpose of Butterworth filter in ' mfilename])
        end
    case 'Chebychev I'
        switch sPurpose
            case 'Lowpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.LPC1O.x;
                    curCMap  = FilterPictures.LPC1O.map;
                else % is even
                    curImage = FilterPictures.LPC1E.x;
                    curCMap  = FilterPictures.LPC1E.map;
                end
            case 'Highpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.HPC1O.x;
                    curCMap  = FilterPictures.HPC1O.map;
                else % is even
                    curImage = FilterPictures.HPC1E.x;
                    curCMap  = FilterPictures.HPC1E.map;                    
                end
            otherwise
                error(['Bad purpose of Chebychev I filter in ' mfilename])
        end
    case 'Chebychev II'
        switch sPurpose
            case 'Lowpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.LPC2O.x;
                    curCMap  = FilterPictures.LPC2O.map;
                else % is even
                    curImage = FilterPictures.LPC2E.x;
                    curCMap  = FilterPictures.LPC2E.map;
                end
            case 'Highpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.HPC2O.x;
                    curCMap  = FilterPictures.HPC2O.map;
                else % is even
                    curImage = FilterPictures.HPC2E.x;
                    curCMap  = FilterPictures.HPC2E.map;                    
                end
            otherwise
                error(['Bad purpose of Chebychev II filter in ' mfilename])
        end
    case 'Elliptic'
        switch sPurpose
            case 'Lowpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.LPEO.x;
                    curCMap  = FilterPictures.LPEO.map;
                else % is even
                    curImage = FilterPictures.LPEE.x;
                    curCMap  = FilterPictures.LPEE.map;
                end
            case 'Highpass'
                if mod(nOrder,2) % if is odd
                    curImage = FilterPictures.HPEO.x;
                    curCMap  = FilterPictures.HPEO.map;
                else % is even
                    curImage = FilterPictures.HPEE.x;
                    curCMap  = FilterPictures.HPEE.map;                    
                end
            otherwise
                error(['Bad purpose of Elliptic filter in ' mfilename])
        end
    otherwise
        error(['Bad type of filter in ' mfilename])
end

% associate the image with the axis
hImage = image(curImage, 'Parent', handles.uiaxImage);
set(handles.figSpecifyFilter, 'Colormap', curCMap);

% fix the display details
set(handles.uiaxImage, ...
    'Visible', 'off', ...
    'YDir'   , 'reverse'       , ...
    'XLim'   , get(hImage,'XData'), ...
    'YLim'   , get(hImage,'YData')  ...
    );

Contact us