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 comentarios

David Goodmanson
David Goodmanson el 9 de Abr. de 2020
Editada: David Goodmanson el 10 de Abr. de 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
Titu Thomas el 9 de Abr. de 2020
Fun1 is to be integrated w.r.t 'td' from limit 0 to 1
clc;
clear;
close all;
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);
I=int(fun1,td,0,1);
display(I)

Iniciar sesión para comentar.

Respuestas (2)

Ameer Hamza
Ameer Hamza el 9 de Abr. de 2020
Editada: Ameer Hamza el 9 de Abr. de 2020

0 votos

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
Walter Roberson el 9 de Abr. de 2020

0 votos

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.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 8 de Abr. de 2020

Editada:

el 10 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by