Matlab:Latex命令输出4位有效数字还是一定数量的小数位数? [英] Matlab: latex command to output with 4 significant digits or with certain amount of decimals?

查看:344
本文介绍了Matlab:Latex命令输出4位有效数字还是一定数量的小数位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Matlab中的结果生成一个表.我使用符号框的latex命令.如何指定有效位数?

I want to generate a table for the results in Matlab. I use the symbolic box's latex command. How can I specify the amount of significant digits?

问题个人资料

>> results

results =

    0.0025    0.0024    0.0024

>> latex(vpa(sym(results),4))       #THIS SHOULD PRINT with 4 decimals, how?

ans =

\left(\begin{array}{ccc} 0.0025401858540021748922299593687057 & 0.0023686521873358401535369921475649 & 0.0023649304185866526495374273508787 \end{array}\right)

>> vpa(sym(results),4)

ans =

[ 0.00254, 0.002369, 0.002365]

推荐答案

我认为vpa的语法设置了有效数字的最小数量.您是否尝试设置过精度变量?

I think that syntax for vpa sets the minimum number of significant figures. Did you try setting the variable-precision accuracy?

d1 = digits(4); % records and sets accuracy
latex(vpa(sym(results)))
digits(d1); % restore previous accuracy

这篇关于Matlab:Latex命令输出4位有效数字还是一定数量的小数位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆