Matlab wont shorten answer after format short

感情迁移 提交于 2019-12-11 14:03:26

问题


I'm trying to get matlab to shorten the answer into scientific notation but it continues to display long numbers.

Here is my matlab script:

syms E;
kb=8.617e-5; %eV/k
h=4.136e-15; %eV*s
Ts=5760; %k
q=1; %ev
c=3.0e8; %m/s
theta_s=atan(7e8/1.5e11); %rad

format short
Il_per_area = (q*pi/2)*(1-cos(2*theta_s))*int(((2/h^3*c^2)*E^2)/(exp(E/(kb*Ts-1))),E)

This is the result matlab gave me:

Il_per_area =

(52508430427297951419542428146127404493579145286547868195529063488882991519987*exp((2251799813685248*E)/1134143295600563)*((5070602400912917605986812821504*E^2)/1286281014955706024710845916969 - (4503599627370496*E)/1134143295600563 + 2))/2361183241434822606848

Can someone help me.


回答1:


That is how Matlab deals with symbolic expressions. You can either try substituting a value of E

subs(Il_per_area, 3.2)

or rather, you'd like to see shorter parameters in the answer with the symbolic E:

add one line of variable-precision arithmetic (VPA)

vpa(Il_per_area,4)

The answer is

ans =

2.223e55*exp(1.985*E)*(3.942*E^2 - 3.971*E + 2.0)


来源:https://stackoverflow.com/questions/18807250/matlab-wont-shorten-answer-after-format-short

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