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

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

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003