How to get a very small value rather than 0?
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all; I'm trying to work out a script which should give a ver small value as a result. The problem is that I keep getting 0 instead…
Any help would be really appreciated.
Here's the script:
rho=7860;
B=-1.00000000011701;
BL=23.562;
Bj=46.9362549800797;
k=1;
int1(k)=(exp(-2*BL(k))*(2*exp(2*BL(k))*sin(2*BL(k))+(-4*exp(3*BL(k))-4*exp(BL(k)))*sin(BL(k))+(4*exp(BL(k))-4*exp(3*BL(k)))*cos(BL(k))+exp(4*BL(k))+8*BL(k)*exp(2*BL(k))-1))/(8*Bj(k));
int2(k)=-(exp(-2*BL(k))*(2*exp(2*BL(k))*sin(2*BL(k))+(4*exp(3*BL(k))+4*exp(BL(k)))*sin(BL(k))+(4*exp(BL(k))-4*exp(3*BL(k)))*cos(BL(k))-exp(4*BL(k))+1))/(8*Bj(k));
int3(k)=-(exp(-BL(k))*((exp(2*BL(k))-1)*sin(BL(k))-exp(BL(k))*((exp(BL(k))+exp(-BL(k)))/2)^2+exp(BL(k))*cos(BL(k))^2))/(2*Bj(k));
m_cap1=rho.*(int1+B.^2.*int2+2.*B.*int3);
0 件のコメント
回答 (2 件)
Matt J
2012 年 11 月 19 日
編集済み: Matt J
2012 年 11 月 19 日
You haven't said what variable in your code is the problematic one.
Regardless, computers are inevitably discrete things. If you get too close to 0, then the number will have to get rounded to zero in order to be represented in floating point.
2 件のコメント
Matt J
2012 年 11 月 21 日
編集済み: Matt J
2012 年 11 月 21 日
If Matt Fig's suggestion doesn't work for you (because you don't have the Symbolic Toolbox), then there is this and
and others like it on the FEX.
However, it would be wise to re-evaluate your approach. It looks very dubious to be working with numbers as huge as
>> exp(4*BL)
ans =
8.5386e+40
and still requiring precision<1.
参考
カテゴリ
Help Center および File Exchange で MuPAD についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!