📄 fval.m
字号:
function val_out = fval(co,val_in,gtzero)% FVAL sets parameters in graphical user interfaces%% OUT = FVAL(HDL,IN [,GTZERO])% HDL object handle% IN input value% GTZERO check if output value > 0% ( == 0 to disable, default == 1)% OUT output value%%Author: Federico Milano%Date: 11-Nov-2002%Update: 22-Aug-2003%Version: 1.1.0%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.if nargin == 2 gtzero = 1;endstringa = get(co,'String');callback = get(co,'Callback');a = findstr(callback,' =');if a, nome = ['"',callback(1:a(1)-1),'" '];endtry val_out = eval(stringa);catch val_out = val_in; fm_disp(lasterr,2); returnend[a0, b0] = size(val_out);if isempty(val_out) fm_disp(['Input variable or function "',stringa,'" is empty.'], 2) val_out = val_in; set(co,'String',num2str(val_in))elseif (a0 > 1 | b0 > 1) if a, fm_disp(['Parameter ', nome,'has to be scalar.'], 2), end val_out = val_in; set(co,'String',num2str(val_in))else if gtzero & val_out < 0 stringa = '0'; fm_disp(['Parameter ',nome,'cannot be negative.']), set(co,'String','0') val_out = 0; end if a, fm_disp(['Parameter ',nome,'set to "', stringa,'".']), endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -