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
本文详细介绍了 Matlab 中 input 函数的使用方法及其参数选项。包括如何获取用户的键盘输入并进行表达式评估,以及如何接收字符串输入而不进行评估。此外还提供了实际应用的例子。
570

被折叠的 条评论
为什么被折叠?



