ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
isyes.m
Go to the documentation of this file.
1%> \brief
2%> Return a scalar MATLAB logical that is ``true`` if the
3%> user response to a question on the MATLAB command prompt
4%> is ``Y`` or ``y``, representing YES, otherwise ``false``
5%> if the user response is ``N`` or ``n``.
6%>
7%> \details
8%> This function continues asking the input question for as long as
9%> the user response is not among the accepted answers mentioned above.
10%>
11%> \param[in] question : The input scalar MATLAB string containing the
12%> question to be displayed on the MATLAB prompt.<br>
13%> (**optional**, default = ``""``)
14%>
15%> \return
16%> ``itis`` : The output scalar MATLAB logical that is ``true`` if the
17%> user response to a question on the MATLAB command prompt
18%> is ``Y`` or ``y``, representing YES, otherwise `false`
19%> if the user response is ``N`` or ``n``.<br>
20%>
21%> \interface{isyes}
22%> \code{.m}
23%>
24%> pm.io.isyes()
25%> pm.io.isyes(question)
26%>
27%> \endcode
28%>
29%> \final{isyes}
30%>
31%> \author
32%> \JoshuaOsborne, May 21 2024, 6:00 PM, University of Texas at Arlington<br>
33%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
34%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
35function itis = isyes(question)
36 if nargin == 0
37 msg = "";
38 elseif nargin == 1
39 msg = string(question);
40 end
41 while true
42 % WARNING: MATLAB 2018a compatibility: do NOT convert the arguments to `input()` to string. Arguments must be chars.
43 answer = lower(string(input(msg{:}, 's')));
44 if strcmp(answer, "y")
45 itis = true;
46 break;
47 elseif strcmp(answer, "n")
48 itis = false;
49 break;
50 else
51 disp("Invalid answer. Please enter either y or n, then press enter.");
52 continue;
53 end
54 end
55end
function isyes(in question)
Return a scalar MATLAB logical that is true if the user response to a question on the MATLAB command ...