Unable to convert expression into double array

1 view (last 30 days)
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.

Accepted Answer

Ameer Hamza
Ameer Hamza on 8 Dec 2020
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 Comments
Sikai Wu
Sikai Wu on 8 Dec 2020
vpaintegral(E1,x,[100 300])
Thanks a lot for your advice, I use this code to get the results.

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 9 Dec 2020
[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 Comments
Walter Roberson
Walter Roberson on 9 Dec 2020
Sikau Wu comments
The answer analysis the problem clearly and tell me how to overcome it.
Walter Roberson
Walter Roberson on 9 Dec 2020
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.

Sign in to comment.


Sikai Wu
Sikai Wu on 9 Dec 2020
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.

Community Treasure Hunt

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

Start Hunting!