matlab输出

Format long:显示小数点后15位
Format short:显示小数点后4位
Format bank:显示小数点后2位
Format +:显示矩阵中元素的正负号
Format rat:用分数的形式显示元素
format short e:1.2346e+001


disp([‘the values in the x matrix are: ‘,num2str(x)]) % the values in the x matrix are: 1 2 3 4 5

若提示输入的句子太长,则可以采用如下形式将句子分为若干行显示:
disp(‘this program calculates the day of year given the ‘);
disp(‘special date.’);
显示结果:
this program calculates the day of year given the
special date.

disp(‘一个字符串’)
disp([‘多个字符串’]): disp=([‘Alice is ’ num2str(12) ’ years old!’])


fprintf:格式化输出
支持的输出格式:
%f: 定点格式
%e: 指数格式
%d: 十进制格式(若显示的是整数,则不包括小数点后的零;若是小数,则以指数形式显示)
%g: 以%f和%e中最紧凑的形式显示
%c: 字符格式(每次显示一个字符)
%s: 字符串格式(显示完整的字符)
\n: 换行(使用fprintf可以在同一行中显示字符和数字信息)
\r: 回车
\t: 表格
\b: 退格
例如:fprintf(‘the sum is: %f\n’,sum_x)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值