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 Comments

David Goodmanson
David Goodmanson on 9 Apr 2020
Edited: David Goodmanson on 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.
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)

Sign in to comment.

Answers (2)

Ameer Hamza
Ameer Hamza on 9 Apr 2020
Edited: Ameer Hamza on 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
Walter Roberson
Walter Roberson on 9 Apr 2020
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.

Categories

Find more on Programming in Help Center and File Exchange

Products

Asked:

on 8 Apr 2020

Edited:

on 10 Apr 2020

Community Treasure Hunt

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

Start Hunting!