⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yesnoanswer.m

📁 数值方法和MATLAB实现与应用.zip
💻 M
字号:
function a = yesNoAnswer(msg)
% yesNoAnswer  Prompt user with a question, and return 1 for 'yes' and 0 for 'no'
%
% Synopsis:  a = yesNoAnswer
%            a = yesNoAnswer(msg)
%
% Input:  msg = (string) prompt message printed to command window
%               Default:  msg = 'Continue?'
%
% Output: a = 1 if user enters 'Y', 'y', or any word beginning with 'Y' or 'y',
%             otherwise, a = 0
if nargin<1, msg = 'Continue?';  end
r = input(sprintf('\n\t%s\n\t(''y'' for yes, ''n'' for no)\n',msg),'s');
if isempty(r) | lower(r(1)) == 'n'
  a = 0;
else
  a = 1;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -