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

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003