integration error in matlab
이전 댓글 표시
While integration a function, why does int(function) appear in the comand window instead of actual result. Why doesn't matlab execute the final result. i've attached below a file resembling my issue. could anyone suggest something that could solve the problem
댓글 수: 2
David Goodmanson
2020년 4월 9일
편집: David Goodmanson
2020년 4월 10일
Hi Titu,
could you repost this not as an image but as text? After that, highlighting it and pressing the symbol in the code tab just above would help too. Since it's an image and can't be copied, and since it contains those blowhard integers that the sym engine likes to spew out, it's hard to tell what the function is.
Titu Thomas
2020년 4월 9일
답변 (2개)
Ameer Hamza
2020년 4월 9일
편집: Ameer Hamza
2020년 4월 9일
It is not always possible to express the integral of a function in closed-form using commonly known functions. Your function seems to one such example. It is either too complicated that MATLAB couldn't find a closed-form solution, or the solution does not exist. In such situations, numerical integration is the way to go
syms x y td
vx=5*10^-3;
K=0.17;
w=0.35*10^-3;
rho=789;
cp=2440;
D=K/(rho*cp);
tc=w^2/(4*D);
fun1=(1/1+(2*td/tc))*exp(-2*((x-vx*td)^2+y^2)/(1+td/tc)*w^2);
fun1_numeric = matlabFunction(fun1, 'Vars', [td,x,y]);
X = 1;
Y = 2;
I=integral(@(td) fun1_numeric(td,X,Y), 0, 1);
disp(I);
Result
I =
3.8834
Walter Roberson
2020년 4월 9일
0 개 추천
When the Symbolic Toolbox is not able to integrate a function, then it returns a placeholder int() expression showing where the integral would be and what it would involve. That placeholder integral can be manipulated symbolically, For example if you add together two integrals that have the same bounds, then there are cases where it can combine the two integrals into one integral -- and if the combined integral is one it can recognize the closed form for, then it would go ahead and process it.
Having the placeholder integral is also useful because you can use vpa() to request numeric approximation using extended precision, and you can use double() to request numeric approximation as double precision.
Sometimes when you get an int() placeholder, the key to further process is to add an assumption about the range of a variable.
In the case of this particular function: either there is no closed form formula for the integral, or else it is difficult to find.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!