integration error in matlab
Mostra commenti meno recenti
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 Commenti
David Goodmanson
il 9 Apr 2020
Modificato: David Goodmanson
il 10 Apr 2020
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
il 9 Apr 2020
Risposte (2)
Ameer Hamza
il 9 Apr 2020
Modificato: Ameer Hamza
il 9 Apr 2020
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
1 Commento
Titu Thomas
il 9 Apr 2020
Walter Roberson
il 9 Apr 2020
0 voti
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.
1 Commento
Titu Thomas
il 9 Apr 2020
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!