📄 checkscale.m
字号:
function checkScale(val)%checkScale Check an entered value, query user about sec/ms if unreasonable.%% askedYet = checkScale(askedYet, val)% If val > 5, ask whether the delays are in ms, not s.% If val < .05, ask whether the delays are in s, not ms.% Also set up scaleText, for displaying the units.%% Uses global variables scale, scaleText, and askedYet.global scale scaleText askedYetif (strcmp(val, 'init')) if (~exist('scale')) % MATLAB stupidity: exist() changed from v4.2 to v5 scale = []; end if (isempty(scale)) scale = 1; % ==1 if delays are sec, ==1000 if msec scaleText = 'sec'; end askedYet = 0; scaleText = ''; returnendminTime = 1; % if delay is less than this, ask about secondsmaxTime = 5; % if delay is more than this, ask about millisecondsif (~askedYet) if (abs(val) > maxTime & scale == 1) ans = input('Are these time delays all in milliseconds? [y/n] ', 's'); if (length(ans)) if (lower(ans(1)) == 'y') scale = 1000; scaleText = ' (msec)'; end end askedYet = 1; elseif (abs(val) < minTime & val ~= 0 & scale == 1000) ans = input('Are these time delays all in seconds? [y/n] ', 's'); if (length(ans)) if (lower(ans(1)) == 'y') scale = 1; scaleText = ' (sec)'; end end askedYet = 1; endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -