Unable to convert expression into double array

2 次查看(过去 30 天)
syms x
% E1 = -(574936417714633*exp(-(x - 150)^2/5000)*((8183344744316655*cos((pi*x)/100))/288230376151711744 - (7103677074291021*cos((pi*x)/140))/18014398509481984 + (2282254577390745*cos((pi*x)/175))/281474976710656 + (209433984667347*cos((pi*x)/350))/17592186044416 - (4635952013778339*cos((3*pi*x)/350))/18014398509481984 + (3116202096570579*cos((pi*x)/700))/70368744177664 - (1592500999883349*cos((3*pi*x)/700))/70368744177664 + (5286183364156013*sin((pi*x)/100))/2305843009213693952 - (5282470715436721*sin((pi*x)/140))/2251799813685248 + (4930148030865465*sin((pi*x)/175))/1125899906842624 - (3313419311544189*sin((pi*x)/350))/70368744177664 + (5052137790519353*sin((3*pi*x)/350))/18014398509481984 + (8004373085987215*sin((pi*x)/700))/140737488355328 + (5597432279575929*sin((3*pi*x)/700))/562949953421312 - 2888206238924633/70368744177664))/72057594037927936
E2 = -(574936417714633*exp(-(x - 150)^2/5000)*((8823814544749061*cos((pi*x)/100))/2417851639229258349412352 - (66451917855713*cos((pi*x)/50))/37778931862957161709568 - (7396681414274859*cos((pi*x)/40))/4835703278458516698824704 - (6468445020191767*cos((3*pi*x)/100))/9671406556917033397649408 + (1163326145497647*cos((pi*x)/200))/151115727451828646838272 - (804955420280903*cos((3*pi*x)/200))/19342813113834066795298816 - (8501245438962469*cos((7*pi*x)/200))/77371252455336267181195264 + (4739840162395179*sin((pi*x)/40))/1208925819614629174706176 + (5198608414617587*sin((pi*x)/50))/604462909807314587353088 + (4351639281487411*sin((pi*x)/100))/302231454903657293676544 + (2791257967313459*sin((3*pi*x)/100))/2417851639229258349412352 + (1458476753937829*sin((pi*x)/200))/151115727451828646838272 + (4006877253789739*sin((3*pi*x)/200))/302231454903657293676544 + (7621631973170679*sin((7*pi*x)/200))/38685626227668133590597632 + 2646175801254393/604462909807314587353088))/72057594037927936
Rone=int(E2,x,100, 300)
double(Rone)
I want to get the integrate value of E1, but when I run the codes, it said that Unable to convert expression into double array. But when I calculated the integrate value of E2, I can get the result. Could you please tell me how to get the integratation value of E1? Thanks a lot for your advice.

采纳的回答

Ameer Hamza
Ameer Hamza 2020-12-8
It seems that some terms in your integral cannot be solved symbolically therefore MATLAB throws this error. You can try to calculate the numerical integral using vpaintegral()
syms x
E1 = -(574936417714633*exp(-(x - 150)^2/5000)*((8183344744316655*cos((pi*x)/100))/288230376151711744 - (7103677074291021*cos((pi*x)/140))/18014398509481984 + (2282254577390745*cos((pi*x)/175))/281474976710656 + (209433984667347*cos((pi*x)/350))/17592186044416 - (4635952013778339*cos((3*pi*x)/350))/18014398509481984 + (3116202096570579*cos((pi*x)/700))/70368744177664 - (1592500999883349*cos((3*pi*x)/700))/70368744177664 + (5286183364156013*sin((pi*x)/100))/2305843009213693952 - (5282470715436721*sin((pi*x)/140))/2251799813685248 + (4930148030865465*sin((pi*x)/175))/1125899906842624 - (3313419311544189*sin((pi*x)/350))/70368744177664 + (5052137790519353*sin((3*pi*x)/350))/18014398509481984 + (8004373085987215*sin((pi*x)/700))/140737488355328 + (5597432279575929*sin((3*pi*x)/700))/562949953421312 - 2888206238924633/70368744177664))/72057594037927936
% E2 = -(574936417714633*exp(-(x - 150)^2/5000)*((8823814544749061*cos((pi*x)/100))/2417851639229258349412352 - (66451917855713*cos((pi*x)/50))/37778931862957161709568 - (7396681414274859*cos((pi*x)/40))/4835703278458516698824704 - (6468445020191767*cos((3*pi*x)/100))/9671406556917033397649408 + (1163326145497647*cos((pi*x)/200))/151115727451828646838272 - (804955420280903*cos((3*pi*x)/200))/19342813113834066795298816 - (8501245438962469*cos((7*pi*x)/200))/77371252455336267181195264 + (4739840162395179*sin((pi*x)/40))/1208925819614629174706176 + (5198608414617587*sin((pi*x)/50))/604462909807314587353088 + (4351639281487411*sin((pi*x)/100))/302231454903657293676544 + (2791257967313459*sin((3*pi*x)/100))/2417851639229258349412352 + (1458476753937829*sin((pi*x)/200))/151115727451828646838272 + (4006877253789739*sin((3*pi*x)/200))/302231454903657293676544 + (7621631973170679*sin((7*pi*x)/200))/38685626227668133590597632 + 2646175801254393/604462909807314587353088))/72057594037927936
Rone=vpaintegral(E1,x,100, 300)
double(Rone)

更多回答(2 个)

Walter Roberson
Walter Roberson 2020-12-9
[I was just about to post this when I had a network outage. I just got back to my computer... so it is a bit late.]
MATLAB simply is not powerful enough to integrate that. It does have a closed-form integral, involving a number of erf() of complex values.
You can use vpaintegral() .
It is obvious from the expression that you integrated an expression that had a number of floating point constants. Floating point constants express uncertainty -- for example 1.23 expresses "some indeterminate number between 1225/1000 inclusive and 1235/1000 exclusive". When you have floating point constants in a int() then you are almost certainly doing the wrong thing -- asking for an exact solution to a problem whose values are not exactly known.
  2 个评论
Walter Roberson
Walter Roberson 2020-12-9
Sikau Wu comments
The answer analysis the problem clearly and tell me how to overcome it.
Walter Roberson
Walter Roberson 2020-12-9
E1 and E2 both do have closed form solutions involving a lot of large rational numbers and a number of erf() calls such as erf(3/8*2^(1/2)*(1i*pi+4)) -- but MATLAB just is not powerful enough to calculate it without further guideance.

请先登录,再进行评论。


Sikai Wu
Sikai Wu 2020-12-9
Thanks a lot for your help. I got the points why it happened. Maybe it is luckly for me to calculte the result by int() for E2 function.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by