
Matlab中的输出命令~向高手求救~
Matlab能实现如C++中能实现的如“cout<<'某字符串'<<x”的功能吗?其中x是某个变量。我的意思是输出时把字符串和x的值输出在同一行。disp函数只能输出某个...
Matlab能实现如C++中能实现的如“cout<<'某字符串'<<x”的功能吗?其中x是某个变量。我的意思是输出时把字符串和x的值输出在同一行。disp函数只能输出某个矩阵的值或是某个字符串,但不能同时输出这两种类型吧?
展开
1个回答
展开全部
Command
Result
sprintf('%0.5g',(1+sqrt(5))/2) 1.618
sprintf('%0.5g',1/eps) 4.5036e+15
sprintf('%15.5f',1/eps) 4503599627370496.00000
sprintf('%d',round(pi)) 3
sprintf('%s','hello') hello
sprintf('The array is %dx%d.',2,3) The array is 2x3
sprintf('\n') Line termination character on all platforms
sprintf函数和C的printf差不多,上面是帮助里的例子,你看看吧.cout比较灵活,但MATLAB主要是从C那里学来的.
sprintf('The array is %dx%d.',2,3) The array is 2x3
这句就和C基本一样了.
Result
sprintf('%0.5g',(1+sqrt(5))/2) 1.618
sprintf('%0.5g',1/eps) 4.5036e+15
sprintf('%15.5f',1/eps) 4503599627370496.00000
sprintf('%d',round(pi)) 3
sprintf('%s','hello') hello
sprintf('The array is %dx%d.',2,3) The array is 2x3
sprintf('\n') Line termination character on all platforms
sprintf函数和C的printf差不多,上面是帮助里的例子,你看看吧.cout比较灵活,但MATLAB主要是从C那里学来的.
sprintf('The array is %dx%d.',2,3) The array is 2x3
这句就和C基本一样了.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |