matlab输出语句有两种,分别是:1、自由格式,语法如“disp(23+454-29*4)”;2、格式化输出,语法如“fprintf('The area is %8.5f\n',area)”。
MATLAB的输入与输出语句
1.MATLAB的输入语句input函数用于接收用户的输入:
a.输入数据>> x=input('please input a number:')
please input a number:22
x =
22
b.输入字符串>> x=input('please input a string:','s')
please input a string:this is a string
x =
this is a string
2.MATLAB输出语句包括自由格式(disp)和格式化输出(fprintf)两种>> disp(23+454-29*4)
361
>> disp([11 22 33;44 55 66;77 88 99])
11 22 33
44 55 66
77 88 99
>> disp('this is a string')
this is a string
>> area=12.56637889;
>> fprintf('The area is %8.5f\n',area)
The area is 12.56638
>>