Matlab输入help input
input Prompt for user input.
NUM = input(PROMPT) displays the PROMPT string on the screen, waits for
input from the keyboard, evaluates any expressions in the input, and
returns the value in NUM. To evaluate expressions, input accesses
variables in the current workspace. If you press the return key without
entering anything, input returns an empty matrix.
STR = input(PROMPT,'s') returns the entered text as a MATLAB string,
without evaluating expressions.
To create a prompt that spans several lines, use '\n' to indicate each
new line. To include a backslash ('\') in the prompt, use '\\'.
Example:
reply = input('Do you want more? Y/N [Y]:','s');
if isempty(reply)
reply = 'Y';
end
注释:input是Matlab中的输入命令,如果reply=input('Do you want more? Y/N [Y]:');则将输入值赋给reply,reply为double类型,若reply = input('Do you want more? Y/N [Y]:','s'); 's'的意思是将输入值看作字符串赋给reply,reply为char类型,可用class(reply)查看reply的类型,例子中isempty(reply)是判断reply是否为空,为空返回真,值为1,不为空返回假,值为0