回复: Matlab的输出语句怎么用?
首先,你要确定你要把待输出的内容输出到哪里,是文件里还是commend window。fprintf是把数据以一定格式输出到一个文件里,disp是将提示字符串或变量值输出到commend window,还可以输出一个超链接。如:
fprintf:
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp.txt', 'wt');%需要先打开一个文件
fprintf(fid, '%6.2f %12.8f\n', y); %
fclose(fid)
disp:
disp(' Corn Oats Hay')
disp(rand(5,3))
结果在命令窗口显示:
Corn Oats Hay
0.2113 0.8474 0.2749
0.0820 0.4524 0.8807
0.7599 0.8075 0.6538
0.0087 0.4832 0.4899
0.8096 0.6135 0.7741
另外:
disp('<a href = "http://www.mathworks.com">The MathWorks Web Site</a>')
显示一个超链接:The MathWorks Web Site
__________________
工科'985'博士,(图像处理、分析及理解;模式识别;运动估计;数据分析等)定做程序、算法实现--qq:752105755
|