matlab输入输出语句(input、disp、fprintf)

matlab输入输出语句(input、disp、fprintf),第1张

matlab输入输出语句(input、disp、fprintf)
  • 输入语句

输入数值

?x=input('please input a number:') please input a number:22 x = 22
输入字符串
?x=input('please input a string:','s') please input a string:this is a string x = this is a string
  • 输出语句
自由格式 (disp)
?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
格式化输出 (fprintf)
 fprintf('The area is %8.5f\n', area) % 注意输出格式前须有%符号

%跳行符号须有\符号The area is 12.56637

%8.5f 输出值为8位数含5位小数

错误消息显示命令 ?error('this is an error') ??? this is an error

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/585470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存