Convert output from symbolic math (sym) to float

假装没事ソ 提交于 2019-11-27 05:41:32

Matlab's symbolic math toolbox contains a function called double.
This function converts the result of the solve function - which is a sym - to a double:

double(a)

ans =

      5.98921078320145
     0.834834535131742

While double is correct, it is limited to the precision of 64bit floating points. Use vpa if a higher precision is needed:

>> vpa(a)

ans =

  5.9892107832014511063435699584181
 0.83483453513174202459587915406938

>> digits(99)

>> vpa(a)

ans =

  5.98921078320145110634356995841813862213621375395128614574627036653958858547362556353272837962692249
 0.834834535131742024595879154069378868157531819123064337100994463734092031618244369410214559292265698
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!