Why am i getting an Inf value when i am calculating definite integral in symbolic math toolbox?
3 次查看(过去 30 天)
显示 更早的评论
I am calculating definite integral of a polynomial using syms command, using the following code: Lb=[-4 -4 -4 -4]; Ub=[4 4 4 4];d=4; n=4; for i=1:n; nx(i,:)=Lb+(Ub-Lb).*rand(1,d); end; syms s t; H= (s^3+7*s^2+24*s+24)/(s^5+10*s^4+35*s^3+50*s^2+24*s); h=(nx(1,1)*s+nx(1,2))/(s^3+nx(1,3)*s^2+nx(1,4)*s); Y=ilaplace(H,s,t); y=ilaplace(h,s,t); Ise=int((Y-y)^2,t,0,inf); ISE=double(Ise)
The problem is when i pick values from matrix nx and put them into h, then for every value of the nx matrix i get ISE=Inf, but when i manually put h, then it calculates ISE. For example, for the following code ISE is being calculated: syms s t; H= (s^3+7*s^2+24*s+24)/(s^5+10*s^4+35*s^3+50*s^2+24*s); h=(16*s+24)/(30*s^3+42*s^2+24*s); Y=ilaplace(H,s,t); y=ilaplace(h,s,t); Ise=int((Y-y)^2,t,0,inf); ISE=double(Ise) Can anyone please let me know where am i wrong and why am i getting Inf value for ISE when i take the coefficients of s in h from nx. Please help me as soon as possible. Thank you in advance.
0 个评论
采纳的回答
Harshad Deshmane
2014-10-2
I do not think the issue lies in picking the coefficients in "h" from the matrix "nx". I think that the function you are trying to integrate does indeed integrate to "Inf" for these values of the coefficients (I did not actually integrate by hand). You can validate this by manually entering the entries in "nx" as the coefficients in "h". You will notice that this will also return "Inf".
Also, the fact that "int" returns a finite value when you manually input the coefficients is solely due to the actual values of the coefficients you are using, and not because you are manually entering them. Again, you can validate this by creating a matrix "nx" using these coefficients that you provided in the second snippet of code, i.e., 16, 24, 42, 24, and then indexing them as your coefficients. You will notice that it evaluates to a finite value.
So, the issue may lie in the actual values of the coefficients (in "h") for your particular function. Perhaps if the upper limit for integration was finite, you would get a finite answer.
更多回答(1 个)
Alberto
2014-10-1
Your problem is that you are trying to integrate a function say F(y)=(Y-y)^2, but using t as integration variable. That means that F is constant while t variates form 0 to Inf. Matematically that value is infinite.
3 个评论
Alberto
2014-10-2
I guess you should change:
Ise=int((Y-y)^2,t,0,inf)
for this one:
Ise=int((Y-y)^2,Y,0,inf)
that will be infinite too (its a math fact, the parabola has infinite area below). If you need a finite value, then you should also change the upper integration value for a finite one. For example:
Ise=int((Y-y)^2,Y,0,10)
Harshad Deshmane
2014-10-2
The only variables here are "s" (Laplace domain) and "t" (time domain). F = (Y - y)^2 is implicitly a function of "t" alone, since "Y" and "y" are functions of "t". So integrating with respect to "t" is in fact the right approach.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!