文档介绍:
MATLAB中format函数在控制输出格式中的使用方法以下:
format默认格式
formatshort5字长定点数
MATLAB中format函数在控制输出格式中的使用方法以下:
format默认格式
formatshort5字长定点数
formatlong15字长定点数
formatshorte5字长浮点数
formatlonge15字长浮点数
formatshortg
formatlongg
formatloose包含空格和空行
formatlong15字长定点数
formatshorte5字长浮点数
formatlonge15字长浮点数
formatshortg
formatlongg
formathex16进制
formathex16进制
formatbank
定点钱币形式
formatbank
定点钱币形式
formatrat
小数分数表示
formatrat
小数分数表示
format++,-,空格
format++,-,空格
formatcompact压缩空格
formatcompact压缩空格
formatloose
包含空格和空行
自然也可以不用format命令,可以更正系统的默认设置格式,
File->Preferences->CommandWindow->TextDisplay.
假如想获得分数可以用rats()函数
假如想获得根号,只实用符号表示了,自然用符号表示是全能的。例
如:
1
a=1/3获得
rats(a)获得1/3
a='sqrt(3)'获得sqrt(3)但是这是字符型,要变换成数值型可以
用eval_r(a),或str2num(a).
别的,增补vpa,digits的用法:
在符号计算中,平时计算结果使用有理数形式表示的,有的时候有理数分子分母很长,不便于观察,因此有时希望能将系数表示成数值形式,此时就要用到这两个函数。