(注:本文主要用于笔者熟悉matlab的基本操作,若想了解这些函数的具体信息,建议在matlab的帮助中进行查看,如input的信息,即在命令行窗口输入 doc input)
一、input、disp
1、input——输入
1)、输入数字语法
x = input(prompt)
示例
prompt = 'What is the original value? ';
x = input(prompt)
y = x*10
显示
What is the original value? 3
x =
3
y =
30
2)、输入文本语法
str = input(prompt,'s')
示例
prompt = 'Do you want more? Y/N [Y]: ';
str = input(prompt,'s');
fprintf('you char is %s',str);
显示
Do you want more? Y/N [Y]: N
you char is N
2、disp——输出
语法
disp(X)
示例1——数字和文本
num=10;
str=