Home > m > gui > pzmodel_designer > pzmodel_helper.m

pzmodel_helper

PURPOSE ^

PZMODEL_HELPER M-file for pzmodel_helper.fig

SYNOPSIS ^

function varargout = pzmodel_helper(varargin)

DESCRIPTION ^

 PZMODEL_HELPER M-file for pzmodel_helper.fig
      PZMODEL_HELPER, by itself, creates a new PZMODEL_HELPER or raises the existing
      singleton*.

      H = PZMODEL_HELPER returns the handle to a new PZMODEL_HELPER or the handle to
      the existing singleton*.

      PZMODEL_HELPER('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in PZMODEL_HELPER.M with the given input arguments.

      PZMODEL_HELPER('Property','Value',...) creates a new PZMODEL_HELPER or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before pzmodel_helper_OpeningFunction gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to pzmodel_helper_OpeningFcn via varargin.

      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
      instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES

 $Id: pzmodel_helper.m,v 1.10 2008/08/04 13:28:03 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = pzmodel_helper(varargin)
0002 % PZMODEL_HELPER M-file for pzmodel_helper.fig
0003 %      PZMODEL_HELPER, by itself, creates a new PZMODEL_HELPER or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = PZMODEL_HELPER returns the handle to a new PZMODEL_HELPER or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      PZMODEL_HELPER('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in PZMODEL_HELPER.M with the given input arguments.
0011 %
0012 %      PZMODEL_HELPER('Property','Value',...) creates a new PZMODEL_HELPER or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before pzmodel_helper_OpeningFunction gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to pzmodel_helper_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 %
0023 % $Id: pzmodel_helper.m,v 1.10 2008/08/04 13:28:03 hewitson Exp $
0024 %
0025 
0026 
0027 % Edit the above text to modify the response to help pzmodel_helper
0028 
0029 % Last Modified by GUIDE v2.5 19-Apr-2007 10:37:13
0030 
0031 % Begin initialization code - DO NOT EDIT
0032 gui_Singleton = 1;
0033 gui_State = struct('gui_Name',       mfilename, ...
0034                    'gui_Singleton',  gui_Singleton, ...
0035                    'gui_OpeningFcn', @pzmodel_helper_OpeningFcn, ...
0036                    'gui_OutputFcn',  @pzmodel_helper_OutputFcn, ...
0037                    'gui_LayoutFcn',  [] , ...
0038                    'gui_Callback',   []);
0039 if nargin && ischar(varargin{1})
0040     gui_State.gui_Callback = str2func(varargin{1});
0041 end
0042 
0043 if nargout
0044     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0045 else
0046     gui_mainfcn(gui_State, varargin{:});
0047 end
0048 % End initialization code - DO NOT EDIT
0049 
0050 
0051 % --- Executes just before pzmodel_helper is made visible.
0052 function pzmodel_helper_OpeningFcn(hObject, eventdata, handles, varargin)
0053 % This function has no output args, see OutputFcn.
0054 % hObject    handle to figure
0055 % eventdata  reserved - to be defined in a future version of MATLAB
0056 % handles    structure with handles and user data (see GUIDATA)
0057 % varargin   command line arguments to pzmodel_helper (see VARARGIN)
0058 
0059 % Choose default command line output for pzmodel_helper
0060 handles.output = hObject;
0061 
0062 % Update handles structure
0063 guidata(hObject, handles);
0064 
0065 % UIWAIT makes pzmodel_helper wait for user response (see UIRESUME)
0066 % uiwait(handles.main);
0067 
0068 % create empty lists
0069 poles = [];
0070 zeros = [];
0071 
0072 setappdata(handles.main, 'poles', poles);
0073 setappdata(handles.main, 'zeros', zeros);
0074 setappdata(handles.main, 'filt', []);
0075 
0076 % --- Outputs from this function are returned to the command line.
0077 function varargout = pzmodel_helper_OutputFcn(hObject, eventdata, handles) 
0078 % varargout  cell array for returning output args (see VARARGOUT);
0079 % hObject    handle to figure
0080 % eventdata  reserved - to be defined in a future version of MATLAB
0081 % handles    structure with handles and user data (see GUIDATA)
0082 
0083 % Get default command line output from handles structure
0084 varargout{1} = handles.output;
0085 
0086 
0087 
0088 function pzEdit_Callback(hObject, eventdata, handles)
0089 % hObject    handle to pzEdit (see GCBO)
0090 % eventdata  reserved - to be defined in a future version of MATLAB
0091 % handles    structure with handles and user data (see GUIDATA)
0092 
0093 % Hints: get(hObject,'String') returns contents of pzEdit as text
0094 %        str2double(get(hObject,'String')) returns contents of pzEdit as a double
0095 
0096 
0097 % --- Executes during object creation, after setting all properties.
0098 function pzEdit_CreateFcn(hObject, eventdata, handles)
0099 % hObject    handle to pzEdit (see GCBO)
0100 % eventdata  reserved - to be defined in a future version of MATLAB
0101 % handles    empty - handles not created until after all CreateFcns called
0102 
0103 % Hint: edit controls usually have a white background on Windows.
0104 %       See ISPC and COMPUTER.
0105 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0106     set(hObject,'BackgroundColor','white');
0107 end
0108 
0109 
0110 % --- Executes on button press in addPoleBtn.
0111 function addPoleBtn_Callback(hObject, eventdata, handles)
0112 % hObject    handle to addPoleBtn (see GCBO)
0113 % eventdata  reserved - to be defined in a future version of MATLAB
0114 % handles    structure with handles and user data (see GUIDATA)
0115 
0116 % get values from pzEdit
0117 strVal = get(handles.pzEdit, 'String');
0118 val    = str2num(strVal);
0119 f      = val(1);
0120 if length(val) == 2
0121   q = val(2);
0122   p = pz(f,q);
0123 else
0124   p = pz(f);
0125 end
0126 
0127 poles = getappdata(handles.main, 'poles');
0128 poles = [poles p];
0129 setappdata(handles.main, 'poles', poles);
0130 
0131 % update list
0132 updatePolesList(handles);
0133 
0134 % update model
0135 updateModelResp(handles);
0136 
0137 
0138 % --- Executes on selection change in poleList.
0139 function poleList_Callback(hObject, eventdata, handles)
0140 % hObject    handle to poleList (see GCBO)
0141 % eventdata  reserved - to be defined in a future version of MATLAB
0142 % handles    structure with handles and user data (see GUIDATA)
0143 
0144 % Hints: contents = get(hObject,'String') returns poleList contents as cell array
0145 %        contents{get(hObject,'Value')} returns selected item from poleList
0146 
0147 
0148 % --- Executes during object creation, after setting all properties.
0149 function poleList_CreateFcn(hObject, eventdata, handles)
0150 % hObject    handle to poleList (see GCBO)
0151 % eventdata  reserved - to be defined in a future version of MATLAB
0152 % handles    empty - handles not created until after all CreateFcns called
0153 
0154 % Hint: listbox controls usually have a white background on Windows.
0155 %       See ISPC and COMPUTER.
0156 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0157     set(hObject,'BackgroundColor','white');
0158 end
0159 
0160 
0161 % --- Executes on button press in addZeroBtn.
0162 function addZeroBtn_Callback(hObject, eventdata, handles)
0163 % hObject    handle to addZeroBtn (see GCBO)
0164 % eventdata  reserved - to be defined in a future version of MATLAB
0165 % handles    structure with handles and user data (see GUIDATA)
0166 
0167 % get values from pzEdit
0168 strVal = get(handles.pzEdit, 'String');
0169 val    = str2num(strVal);
0170 f      = val(1);
0171 if length(val) == 2
0172   q = val(2);
0173   z = pz(f,q);
0174 else
0175   z = pz(f);
0176 end
0177 
0178 zeros = getappdata(handles.main, 'zeros');
0179 zeros = [zeros z];
0180 setappdata(handles.main, 'zeros', zeros);
0181 
0182 % update list
0183 updateZerosList(handles);
0184 
0185 % update model
0186 updateModelResp(handles);
0187 
0188 
0189 % --- Executes on selection change in zeroList.
0190 function zeroList_Callback(hObject, eventdata, handles)
0191 % hObject    handle to zeroList (see GCBO)
0192 % eventdata  reserved - to be defined in a future version of MATLAB
0193 % handles    structure with handles and user data (see GUIDATA)
0194 
0195 % Hints: contents = get(hObject,'String') returns zeroList contents as cell array
0196 %        contents{get(hObject,'Value')} returns selected item from zeroList
0197 
0198 
0199 % --- Executes during object creation, after setting all properties.
0200 function zeroList_CreateFcn(hObject, eventdata, handles)
0201 % hObject    handle to zeroList (see GCBO)
0202 % eventdata  reserved - to be defined in a future version of MATLAB
0203 % handles    empty - handles not created until after all CreateFcns called
0204 
0205 % Hint: listbox controls usually have a white background on Windows.
0206 %       See ISPC and COMPUTER.
0207 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0208     set(hObject,'BackgroundColor','white');
0209 end
0210 
0211 %----------- Update Poles List -----------------------------
0212 function updatePolesList(handles)
0213 
0214 poles = getappdata(handles.main, 'poles');
0215 pstr = [];
0216 for n=1:length(poles)
0217   p = poles(n);
0218   f = p.f;
0219   q = p.q;
0220   if q>0.5
0221     pstr = strvcat(pstr, sprintf('%2.2f Hz   Q=%2.2f', f, q));
0222   else
0223     pstr = strvcat(pstr, sprintf('%2.2f Hz', f));
0224   end
0225 end
0226 
0227 if isempty(poles)
0228   set(handles.poleList, 'String', '  ');
0229 else
0230   set(handles.poleList, 'String', pstr);
0231 end
0232 set(handles.poleList, 'Value', 1);
0233 
0234 %----------- Update Zeros List -----------------------------
0235 function updateZerosList(handles)
0236 
0237 zeros = getappdata(handles.main, 'zeros');
0238 pstr = [];
0239 for n=1:length(zeros)
0240   p = zeros(n);
0241   f = p.f;
0242   q = p.q;
0243   if q>0.5
0244     pstr = strvcat(pstr, sprintf('%2.2f Hz   Q=%2.2f', f, q));
0245   else
0246     pstr = strvcat(pstr, sprintf('%2.2f Hz', f));
0247   end
0248 end
0249 
0250 if isempty(zeros)
0251   set(handles.zeroList, 'String', '  ');
0252 else
0253   set(handles.zeroList, 'String', pstr);
0254 end
0255 set(handles.zeroList, 'Value', 1);
0256 
0257 %----------- Update Model response -----------------------------
0258 function updateModelResp(handles)
0259 
0260 gain = str2double(get(handles.gainEdit, 'String'));
0261 poles = getappdata(handles.main, 'poles');
0262 zeros = getappdata(handles.main, 'zeros');
0263 
0264 pzm = pzmodel(gain, poles, zeros);
0265 
0266 f1s = get(handles.f1Edit, 'String');
0267 f2s = get(handles.f2Edit, 'String');
0268 nfs = get(handles.nfEdit, 'String');
0269 fss = get(handles.fsEdit, 'String');
0270 
0271 if isempty(f1s)
0272   f1 = getlowerFreq(pzm)/10;
0273 else
0274   f1 = str2double(f1s);
0275 end
0276 if isempty(f2s)
0277   f2 = getupperFreq(pzm)*10;
0278 else
0279   f2 = str2double(f2s);
0280 end
0281 if isempty(nfs)
0282   nf = 1000;
0283 else
0284   nf = str2double(nfs);
0285 end
0286 
0287 if ~isempty(pzm.poles) || ~isempty(pzm.zeros)
0288 
0289   % make model response
0290   a  = resp(pzm, f1, f2, nf);
0291   d  = a.data;
0292   mx = d.x;
0293   my = d.y;
0294 
0295   % make IIR response
0296   if isempty(fss)
0297     filt     = miir(plist([param('pzmodel', pzm)]));
0298   else
0299     filt     = miir(plist([param('pzmodel', pzm) param('fs', str2double(fss))]));
0300   end
0301   setappdata(handles.main, 'filt', filt);
0302   set(handles.filterStrEdit, 'String', string(filt));
0303 
0304   filtresp = resp(filt, plist(param('f', mx.')));
0305   d        = filtresp.data;
0306   fx       = d.x;
0307   fy       = d.y;
0308 
0309   axes(handles.magAxes) % Select the proper axes
0310   loglog(mx,abs(my), fx, abs(fy), 'r--')
0311   grid on;
0312   axis tight
0313   xlabel('');
0314   ylabel('Magnitude');
0315   legend('Pole/Zero model', 'IIR','Location','SouthWest')
0316 
0317   axes(handles.phaseAxes) % Select the proper axes
0318   semilogx(mx, utils.math.phase(my), fx, utils.math.phase(fy), 'r--')
0319   grid on;
0320   axis tight
0321   xlabel('Frequency [Hz]');
0322   ylabel('Phase [deg]');
0323 else
0324   axes(handles.magAxes) % Select the proper axes
0325   cla
0326   axes(handles.phaseAxes) % Select the proper axes
0327   cla
0328 end
0329 
0330 
0331 
0332 
0333 function gainEdit_Callback(hObject, eventdata, handles)
0334 % hObject    handle to gainEdit (see GCBO)
0335 % eventdata  reserved - to be defined in a future version of MATLAB
0336 % handles    structure with handles and user data (see GUIDATA)
0337 
0338 % Hints: get(hObject,'String') returns contents of gainEdit as text
0339 %        str2double(get(hObject,'String')) returns contents of gainEdit as a double
0340 
0341 updateModelResp(handles)
0342 
0343 % --- Executes during object creation, after setting all properties.
0344 function gainEdit_CreateFcn(hObject, eventdata, handles)
0345 % hObject    handle to gainEdit (see GCBO)
0346 % eventdata  reserved - to be defined in a future version of MATLAB
0347 % handles    empty - handles not created until after all CreateFcns called
0348 
0349 % Hint: edit controls usually have a white background on Windows.
0350 %       See ISPC and COMPUTER.
0351 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0352     set(hObject,'BackgroundColor','white');
0353 end
0354 
0355 
0356 
0357 function f1Edit_Callback(hObject, eventdata, handles)
0358 % hObject    handle to f1Edit (see GCBO)
0359 % eventdata  reserved - to be defined in a future version of MATLAB
0360 % handles    structure with handles and user data (see GUIDATA)
0361 
0362 % Hints: get(hObject,'String') returns contents of f1Edit as text
0363 %        str2double(get(hObject,'String')) returns contents of f1Edit as a double
0364 
0365 
0366 % --- Executes during object creation, after setting all properties.
0367 function f1Edit_CreateFcn(hObject, eventdata, handles)
0368 % hObject    handle to f1Edit (see GCBO)
0369 % eventdata  reserved - to be defined in a future version of MATLAB
0370 % handles    empty - handles not created until after all CreateFcns called
0371 
0372 % Hint: edit controls usually have a white background on Windows.
0373 %       See ISPC and COMPUTER.
0374 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0375     set(hObject,'BackgroundColor','white');
0376 end
0377 
0378 
0379 
0380 function f2Edit_Callback(hObject, eventdata, handles)
0381 % hObject    handle to f2Edit (see GCBO)
0382 % eventdata  reserved - to be defined in a future version of MATLAB
0383 % handles    structure with handles and user data (see GUIDATA)
0384 
0385 % Hints: get(hObject,'String') returns contents of f2Edit as text
0386 %        str2double(get(hObject,'String')) returns contents of f2Edit as a double
0387 
0388 
0389 % --- Executes during object creation, after setting all properties.
0390 function f2Edit_CreateFcn(hObject, eventdata, handles)
0391 % hObject    handle to f2Edit (see GCBO)
0392 % eventdata  reserved - to be defined in a future version of MATLAB
0393 % handles    empty - handles not created until after all CreateFcns called
0394 
0395 % Hint: edit controls usually have a white background on Windows.
0396 %       See ISPC and COMPUTER.
0397 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0398     set(hObject,'BackgroundColor','white');
0399 end
0400 
0401 
0402 
0403 function nfEdit_Callback(hObject, eventdata, handles)
0404 % hObject    handle to nfEdit (see GCBO)
0405 % eventdata  reserved - to be defined in a future version of MATLAB
0406 % handles    structure with handles and user data (see GUIDATA)
0407 
0408 % Hints: get(hObject,'String') returns contents of nfEdit as text
0409 %        str2double(get(hObject,'String')) returns contents of nfEdit as a double
0410 
0411 
0412 % --- Executes during object creation, after setting all properties.
0413 function nfEdit_CreateFcn(hObject, eventdata, handles)
0414 % hObject    handle to nfEdit (see GCBO)
0415 % eventdata  reserved - to be defined in a future version of MATLAB
0416 % handles    empty - handles not created until after all CreateFcns called
0417 
0418 % Hint: edit controls usually have a white background on Windows.
0419 %       See ISPC and COMPUTER.
0420 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0421     set(hObject,'BackgroundColor','white');
0422 end
0423 
0424 
0425 % --- Executes on button press in replotBtn.
0426 function replotBtn_Callback(hObject, eventdata, handles)
0427 % hObject    handle to replotBtn (see GCBO)
0428 % eventdata  reserved - to be defined in a future version of MATLAB
0429 % handles    structure with handles and user data (see GUIDATA)
0430 
0431 updateModelResp(handles)
0432 
0433 
0434 
0435 function fsEdit_Callback(hObject, eventdata, handles)
0436 % hObject    handle to fsEdit (see GCBO)
0437 % eventdata  reserved - to be defined in a future version of MATLAB
0438 % handles    structure with handles and user data (see GUIDATA)
0439 
0440 % Hints: get(hObject,'String') returns contents of fsEdit as text
0441 %        str2double(get(hObject,'String')) returns contents of fsEdit as a double
0442 updateModelResp(handles)
0443 
0444 
0445 % --- Executes during object creation, after setting all properties.
0446 function fsEdit_CreateFcn(hObject, eventdata, handles)
0447 % hObject    handle to fsEdit (see GCBO)
0448 % eventdata  reserved - to be defined in a future version of MATLAB
0449 % handles    empty - handles not created until after all CreateFcns called
0450 
0451 % Hint: edit controls usually have a white background on Windows.
0452 %       See ISPC and COMPUTER.
0453 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0454     set(hObject,'BackgroundColor','white');
0455 end
0456 
0457 
0458 % --- Executes on button press in figureBtn.
0459 function figureBtn_Callback(hObject, eventdata, handles)
0460 % hObject    handle to figureBtn (see GCBO)
0461 % eventdata  reserved - to be defined in a future version of MATLAB
0462 % handles    structure with handles and user data (see GUIDATA)
0463 
0464 gain = str2double(get(handles.gainEdit, 'String'));
0465 poles = getappdata(handles.main, 'poles');
0466 zeros = getappdata(handles.main, 'zeros');
0467 
0468 pzm = pzmodel(gain, poles, zeros);
0469 
0470 f1s = get(handles.f1Edit, 'String');
0471 f2s = get(handles.f2Edit, 'String');
0472 nfs = get(handles.nfEdit, 'String');
0473 fss = get(handles.fsEdit, 'String');
0474 
0475 if isempty(f1s)
0476   f1 = getlowerFreq(pzm)/10;
0477 else
0478   f1 = str2double(f1s);
0479 end
0480 if isempty(f2s)
0481   f2 = getupperFreq(pzm)*10;
0482 else
0483   f2 = str2double(f2s);
0484 end
0485 if isempty(nfs)
0486   nf = 1000;
0487 else
0488   nf = str2double(nfs);
0489 end
0490 
0491 % make model response
0492 a  = resp(pzm, f1, f2, nf);
0493 a.setName('PZmodel');
0494 
0495 % make IIR response
0496 if isempty(fss)
0497   filt     = miir(plist([param('pzmodel', pzm)]));
0498 else
0499   filt     = miir(plist([param('pzmodel', pzm) param('fs', str2double(fss))]));
0500 end
0501 
0502 
0503 filtresp = resp(filt, plist(param('f', a.data.getX)));
0504 filtresp.setName('IIR filter');
0505 
0506 iplot(a, filtresp)
0507 
0508 
0509 
0510 function filterStrEdit_Callback(hObject, eventdata, handles)
0511 % hObject    handle to filterStrEdit (see GCBO)
0512 % eventdata  reserved - to be defined in a future version of MATLAB
0513 % handles    structure with handles and user data (see GUIDATA)
0514 
0515 % Hints: get(hObject,'String') returns contents of filterStrEdit as text
0516 %        str2double(get(hObject,'String')) returns contents of filterStrEdit as a double
0517 
0518 
0519 % --- Executes during object creation, after setting all properties.
0520 function filterStrEdit_CreateFcn(hObject, eventdata, handles)
0521 % hObject    handle to filterStrEdit (see GCBO)
0522 % eventdata  reserved - to be defined in a future version of MATLAB
0523 % handles    empty - handles not created until after all CreateFcns called
0524 
0525 % Hint: edit controls usually have a white background on Windows.
0526 %       See ISPC and COMPUTER.
0527 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0528     set(hObject,'BackgroundColor','white');
0529 end
0530 
0531 
0532 % --- Executes on button press in clearBtn.
0533 function clearBtn_Callback(hObject, eventdata, handles)
0534 % hObject    handle to clearBtn (see GCBO)
0535 % eventdata  reserved - to be defined in a future version of MATLAB
0536 % handles    structure with handles and user data (see GUIDATA)
0537 
0538 setappdata(handles.main, 'poles', []);
0539 setappdata(handles.main, 'zeros', []);
0540 
0541 % update list
0542 updateZerosList(handles);
0543 updatePolesList(handles);
0544 
0545 % update model
0546 updateModelResp(handles);
0547 
0548 
0549 % --- Executes on button press in deletePolesBtn.
0550 function deletePolesBtn_Callback(hObject, eventdata, handles)
0551 % hObject    handle to deletePolesBtn (see GCBO)
0552 % eventdata  reserved - to be defined in a future version of MATLAB
0553 % handles    structure with handles and user data (see GUIDATA)
0554 
0555 % get selection from list
0556 values = get(handles.poleList, 'Value');
0557 
0558 % get poles
0559 poles = getappdata(handles.main, 'poles');
0560 
0561 po = [];
0562 for j=1:length(poles)
0563   if j~=values
0564     po = [po poles(j)];
0565   end  
0566 end
0567 
0568 setappdata(handles.main, 'poles', po);
0569 updatePolesList(handles);
0570 
0571 % update model
0572 updateModelResp(handles);
0573 
0574 
0575 % --- Executes on button press in deleteZerosBtn.
0576 function deleteZerosBtn_Callback(hObject, eventdata, handles)
0577 % hObject    handle to deleteZerosBtn (see GCBO)
0578 % eventdata  reserved - to be defined in a future version of MATLAB
0579 % handles    structure with handles and user data (see GUIDATA)
0580 
0581 % get selection from list
0582 values = get(handles.zeroList, 'Value');
0583 % get zeros
0584 zeros = getappdata(handles.main, 'zeros');
0585 zo = [];
0586 for j=1:length(zeros)
0587   if j~=values
0588     zo = [zo zeros(j)];
0589   end  
0590 end
0591 
0592 setappdata(handles.main, 'zeros', zo);
0593 updateZerosList(handles);
0594 
0595 % update model
0596 updateModelResp(handles);
0597 
0598 
0599 % --- Executes on button press in saveAObtn.
0600 function saveAObtn_Callback(hObject, eventdata, handles)
0601 % hObject    handle to saveAObtn (see GCBO)
0602 % eventdata  reserved - to be defined in a future version of MATLAB
0603 % handles    structure with handles and user data (see GUIDATA)
0604 
0605 % get response
0606 gain = str2double(get(handles.gainEdit, 'String'));
0607 poles = getappdata(handles.main, 'poles');
0608 zeros = getappdata(handles.main, 'zeros');
0609 pzm = pzmodel(gain, poles, zeros);
0610 
0611 f1s = get(handles.f1Edit, 'String');
0612 f2s = get(handles.f2Edit, 'String');
0613 nfs = get(handles.nfEdit, 'String');
0614 fss = get(handles.fsEdit, 'String');
0615 
0616 if isempty(f1s)
0617   f1 = getlowerFreq(pzm)/10;
0618 else
0619   f1 = str2double(f1s);
0620 end
0621 if isempty(f2s)
0622   f2 = getupperFreq(pzm)*10;
0623 else
0624   f2 = str2double(f2s);
0625 end
0626 if isempty(nfs)
0627   nf = 1000;
0628 else
0629   nf = str2double(nfs);
0630 end
0631 
0632 % make model response
0633 a  = resp(pzm, f1, f2, nf);
0634 
0635 % Get filename
0636 [filename, pathname] = uiputfile('*.xml', 'LTPDA XML file (*.xml)', 'Save as');
0637 if isequal(filename,0) || isequal(pathname,0)
0638 else
0639   fname = fullfile(pathname, filename);
0640   save(a, fname);
0641 end
0642

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003