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.html,v 1.14 2008/03/31 10:27:44 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.html,v 1.14 2008/03/31 10:27:44 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 = pole(f,q);
0123 else
0124   p = pole(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 = zero(f,q);
0174 else
0175   z = zero(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 = get(p, 'f');
0219   q = get(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 = get(p, 'f');
0242   q = get(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 % make model response
0288 a  = resp(pzm, f1, f2, nf);
0289 d  = a.data;
0290 mx = d.x;
0291 my = d.y;
0292 
0293 % make IIR response
0294 if isempty(fss)
0295   filt     = miir(plist([param('pzmodel', pzm)]));
0296 else
0297   filt     = miir(plist([param('pzmodel', pzm) param('fs', str2double(fss))]));
0298 end
0299 setappdata(handles.main, 'filt', filt);
0300 set(handles.filterStrEdit, 'String', string(pzm));
0301 
0302 filtresp = resp(filt, plist(param('f', mx.')));
0303 d        = filtresp.data;
0304 fx       = d.x;
0305 fy       = d.y;
0306 
0307 axes(handles.magAxes) % Select the proper axes
0308 loglog(mx,abs(my), fx, abs(fy), 'r--')
0309 grid on;
0310 axis tight
0311 xlabel('');
0312 ylabel('Magnitude');
0313 legend('Pole/Zero model', 'IIR','Location','SouthWest')
0314 
0315 axes(handles.phaseAxes) % Select the proper axes
0316 semilogx(mx, ltpda_phase(my), fx, ltpda_phase(fy), 'r--')
0317 grid on;
0318 axis tight
0319 xlabel('Frequency [Hz]');
0320 ylabel('Phase [deg]');
0321 
0322 
0323 
0324 
0325 
0326 function gainEdit_Callback(hObject, eventdata, handles)
0327 % hObject    handle to gainEdit (see GCBO)
0328 % eventdata  reserved - to be defined in a future version of MATLAB
0329 % handles    structure with handles and user data (see GUIDATA)
0330 
0331 % Hints: get(hObject,'String') returns contents of gainEdit as text
0332 %        str2double(get(hObject,'String')) returns contents of gainEdit as a double
0333 
0334 updateModelResp(handles)
0335 
0336 % --- Executes during object creation, after setting all properties.
0337 function gainEdit_CreateFcn(hObject, eventdata, handles)
0338 % hObject    handle to gainEdit (see GCBO)
0339 % eventdata  reserved - to be defined in a future version of MATLAB
0340 % handles    empty - handles not created until after all CreateFcns called
0341 
0342 % Hint: edit controls usually have a white background on Windows.
0343 %       See ISPC and COMPUTER.
0344 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0345     set(hObject,'BackgroundColor','white');
0346 end
0347 
0348 
0349 
0350 function f1Edit_Callback(hObject, eventdata, handles)
0351 % hObject    handle to f1Edit (see GCBO)
0352 % eventdata  reserved - to be defined in a future version of MATLAB
0353 % handles    structure with handles and user data (see GUIDATA)
0354 
0355 % Hints: get(hObject,'String') returns contents of f1Edit as text
0356 %        str2double(get(hObject,'String')) returns contents of f1Edit as a double
0357 
0358 
0359 % --- Executes during object creation, after setting all properties.
0360 function f1Edit_CreateFcn(hObject, eventdata, handles)
0361 % hObject    handle to f1Edit (see GCBO)
0362 % eventdata  reserved - to be defined in a future version of MATLAB
0363 % handles    empty - handles not created until after all CreateFcns called
0364 
0365 % Hint: edit controls usually have a white background on Windows.
0366 %       See ISPC and COMPUTER.
0367 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0368     set(hObject,'BackgroundColor','white');
0369 end
0370 
0371 
0372 
0373 function f2Edit_Callback(hObject, eventdata, handles)
0374 % hObject    handle to f2Edit (see GCBO)
0375 % eventdata  reserved - to be defined in a future version of MATLAB
0376 % handles    structure with handles and user data (see GUIDATA)
0377 
0378 % Hints: get(hObject,'String') returns contents of f2Edit as text
0379 %        str2double(get(hObject,'String')) returns contents of f2Edit as a double
0380 
0381 
0382 % --- Executes during object creation, after setting all properties.
0383 function f2Edit_CreateFcn(hObject, eventdata, handles)
0384 % hObject    handle to f2Edit (see GCBO)
0385 % eventdata  reserved - to be defined in a future version of MATLAB
0386 % handles    empty - handles not created until after all CreateFcns called
0387 
0388 % Hint: edit controls usually have a white background on Windows.
0389 %       See ISPC and COMPUTER.
0390 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0391     set(hObject,'BackgroundColor','white');
0392 end
0393 
0394 
0395 
0396 function nfEdit_Callback(hObject, eventdata, handles)
0397 % hObject    handle to nfEdit (see GCBO)
0398 % eventdata  reserved - to be defined in a future version of MATLAB
0399 % handles    structure with handles and user data (see GUIDATA)
0400 
0401 % Hints: get(hObject,'String') returns contents of nfEdit as text
0402 %        str2double(get(hObject,'String')) returns contents of nfEdit as a double
0403 
0404 
0405 % --- Executes during object creation, after setting all properties.
0406 function nfEdit_CreateFcn(hObject, eventdata, handles)
0407 % hObject    handle to nfEdit (see GCBO)
0408 % eventdata  reserved - to be defined in a future version of MATLAB
0409 % handles    empty - handles not created until after all CreateFcns called
0410 
0411 % Hint: edit controls usually have a white background on Windows.
0412 %       See ISPC and COMPUTER.
0413 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0414     set(hObject,'BackgroundColor','white');
0415 end
0416 
0417 
0418 % --- Executes on button press in replotBtn.
0419 function replotBtn_Callback(hObject, eventdata, handles)
0420 % hObject    handle to replotBtn (see GCBO)
0421 % eventdata  reserved - to be defined in a future version of MATLAB
0422 % handles    structure with handles and user data (see GUIDATA)
0423 
0424 updateModelResp(handles)
0425 
0426 
0427 
0428 function fsEdit_Callback(hObject, eventdata, handles)
0429 % hObject    handle to fsEdit (see GCBO)
0430 % eventdata  reserved - to be defined in a future version of MATLAB
0431 % handles    structure with handles and user data (see GUIDATA)
0432 
0433 % Hints: get(hObject,'String') returns contents of fsEdit as text
0434 %        str2double(get(hObject,'String')) returns contents of fsEdit as a double
0435 updateModelResp(handles)
0436 
0437 
0438 % --- Executes during object creation, after setting all properties.
0439 function fsEdit_CreateFcn(hObject, eventdata, handles)
0440 % hObject    handle to fsEdit (see GCBO)
0441 % eventdata  reserved - to be defined in a future version of MATLAB
0442 % handles    empty - handles not created until after all CreateFcns called
0443 
0444 % Hint: edit controls usually have a white background on Windows.
0445 %       See ISPC and COMPUTER.
0446 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0447     set(hObject,'BackgroundColor','white');
0448 end
0449 
0450 
0451 % --- Executes on button press in figureBtn.
0452 function figureBtn_Callback(hObject, eventdata, handles)
0453 % hObject    handle to figureBtn (see GCBO)
0454 % eventdata  reserved - to be defined in a future version of MATLAB
0455 % handles    structure with handles and user data (see GUIDATA)
0456 
0457 gain = str2double(get(handles.gainEdit, 'String'));
0458 poles = getappdata(handles.main, 'poles');
0459 zeros = getappdata(handles.main, 'zeros');
0460 
0461 pzm = pzmodel(gain, poles, zeros);
0462 
0463 f1s = get(handles.f1Edit, 'String');
0464 f2s = get(handles.f2Edit, 'String');
0465 nfs = get(handles.nfEdit, 'String');
0466 fss = get(handles.fsEdit, 'String');
0467 
0468 if isempty(f1s)
0469   f1 = getlowerFreq(pzm)/10;
0470 else
0471   f1 = str2double(f1s);
0472 end
0473 if isempty(f2s)
0474   f2 = getupperFreq(pzm)*10;
0475 else
0476   f2 = str2double(f2s);
0477 end
0478 if isempty(nfs)
0479   nf = 1000;
0480 else
0481   nf = str2double(nfs);
0482 end
0483 
0484 % make model response
0485 a  = resp(pzm, f1, f2, nf);
0486 d  = a.data;
0487 mx = d.x;
0488 my = d.y;
0489 
0490 % make IIR response
0491 if isempty(fss)
0492   filt     = miir(plist([param('pzmodel', pzm)]));
0493 else
0494   filt     = miir(plist([param('pzmodel', pzm) param('fs', str2double(fss))]));
0495 end
0496 
0497 
0498 filtresp = resp(filt, plist(param('f', mx.')));
0499 d        = filtresp.data;
0500 fx       = d.x;
0501 fy       = d.y;
0502 
0503 figure
0504 subplot(3,1,1:2)
0505 loglog(mx,abs(my), fx, abs(fy), 'r--')
0506 grid on;
0507 axis tight
0508 xlabel('');
0509 ylabel('Magnitude');
0510 legend('Pole/Zero model', 'IIR','Location','SouthWest')
0511 
0512 subplot(3,1,3)
0513 semilogx(mx, ltpda_phase(my), fx, ltpda_phase(fy), 'r--')
0514 grid on;
0515 axis tight
0516 xlabel('Frequency [Hz]');
0517 ylabel('Phase [deg]');
0518 
0519 
0520 function filterStrEdit_Callback(hObject, eventdata, handles)
0521 % hObject    handle to filterStrEdit (see GCBO)
0522 % eventdata  reserved - to be defined in a future version of MATLAB
0523 % handles    structure with handles and user data (see GUIDATA)
0524 
0525 % Hints: get(hObject,'String') returns contents of filterStrEdit as text
0526 %        str2double(get(hObject,'String')) returns contents of filterStrEdit as a double
0527 
0528 
0529 % --- Executes during object creation, after setting all properties.
0530 function filterStrEdit_CreateFcn(hObject, eventdata, handles)
0531 % hObject    handle to filterStrEdit (see GCBO)
0532 % eventdata  reserved - to be defined in a future version of MATLAB
0533 % handles    empty - handles not created until after all CreateFcns called
0534 
0535 % Hint: edit controls usually have a white background on Windows.
0536 %       See ISPC and COMPUTER.
0537 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0538     set(hObject,'BackgroundColor','white');
0539 end
0540 
0541 
0542 % --- Executes on button press in clearBtn.
0543 function clearBtn_Callback(hObject, eventdata, handles)
0544 % hObject    handle to clearBtn (see GCBO)
0545 % eventdata  reserved - to be defined in a future version of MATLAB
0546 % handles    structure with handles and user data (see GUIDATA)
0547 
0548 setappdata(handles.main, 'poles', []);
0549 setappdata(handles.main, 'zeros', []);
0550 
0551 % update list
0552 updateZerosList(handles);
0553 updatePolesList(handles);
0554 
0555 % update model
0556 updateModelResp(handles);
0557 
0558 
0559 % --- Executes on button press in deletePolesBtn.
0560 function deletePolesBtn_Callback(hObject, eventdata, handles)
0561 % hObject    handle to deletePolesBtn (see GCBO)
0562 % eventdata  reserved - to be defined in a future version of MATLAB
0563 % handles    structure with handles and user data (see GUIDATA)
0564 
0565 % get selection from list
0566 values = get(handles.poleList, 'Value');
0567 
0568 % get poles
0569 poles = getappdata(handles.main, 'poles');
0570 
0571 po = [];
0572 for j=1:length(poles)
0573   if j~=values
0574     po = [po poles(j)];
0575   end  
0576 end
0577 
0578 setappdata(handles.main, 'poles', po);
0579 updatePolesList(handles);
0580 
0581 % update model
0582 updateModelResp(handles);
0583 
0584 
0585 % --- Executes on button press in deleteZerosBtn.
0586 function deleteZerosBtn_Callback(hObject, eventdata, handles)
0587 % hObject    handle to deleteZerosBtn (see GCBO)
0588 % eventdata  reserved - to be defined in a future version of MATLAB
0589 % handles    structure with handles and user data (see GUIDATA)
0590 
0591 % get selection from list
0592 values = get(handles.zeroList, 'Value');
0593 % get zeros
0594 zeros = getappdata(handles.main, 'zeros');
0595 zo = [];
0596 for j=1:length(zeros)
0597   if j~=values
0598     zo = [zo zeros(j)];
0599   end  
0600 end
0601 
0602 setappdata(handles.main, 'zeros', zo);
0603 updateZerosList(handles);
0604 
0605 % update model
0606 updateModelResp(handles);
0607 
0608 
0609 % --- Executes on button press in saveAObtn.
0610 function saveAObtn_Callback(hObject, eventdata, handles)
0611 % hObject    handle to saveAObtn (see GCBO)
0612 % eventdata  reserved - to be defined in a future version of MATLAB
0613 % handles    structure with handles and user data (see GUIDATA)
0614 
0615 % get response
0616 gain = str2double(get(handles.gainEdit, 'String'));
0617 poles = getappdata(handles.main, 'poles');
0618 zeros = getappdata(handles.main, 'zeros');
0619 pzm = pzmodel(gain, poles, zeros);
0620 
0621 f1s = get(handles.f1Edit, 'String');
0622 f2s = get(handles.f2Edit, 'String');
0623 nfs = get(handles.nfEdit, 'String');
0624 fss = get(handles.fsEdit, 'String');
0625 
0626 if isempty(f1s)
0627   f1 = getlowerFreq(pzm)/10;
0628 else
0629   f1 = str2double(f1s);
0630 end
0631 if isempty(f2s)
0632   f2 = getupperFreq(pzm)*10;
0633 else
0634   f2 = str2double(f2s);
0635 end
0636 if isempty(nfs)
0637   nf = 1000;
0638 else
0639   nf = str2double(nfs);
0640 end
0641 
0642 % make model response
0643 a  = resp(pzm, f1, f2, nf);
0644 
0645 % Get filename
0646 [filename, pathname] = uiputfile('*.xml', 'LTPDA XML file (*.xml)', 'Save as');
0647 if isequal(filename,0) || isequal(pathname,0)
0648 else
0649   fname = fullfile(pathname, filename);
0650   save(a, fname);
0651 end
0652

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003