I am struggling with integrating a function.
Mostrar comentarios más antiguos
I have this function that I have to integrate:

And I added inline function to matlab as such:
f=inline('sqrt(1+((66*x)^2/((1.2*x^2)+3))','x')
f =
Inline function:
f(x) = sqrt(1+((66*x)^2/((1.2*x^2)+3))
However, it gives me this error:
> int(f(x),x)
Error using inlineeval
Error in inline expression ==> sqrt(1+((66*x)^2/((1.2*x^2)+3))
Error: This statement is incomplete.
Error in indexing (line 23)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr); %#ok<DILEVAL>
How can I fix this? I would be so grateful for a help!
5 comentarios
Torsten
el 26 de Ag. de 2023
Integration variable and upper limit of the integral both have the same name (x). That doesn't make sense.
As far as I know, that's a common occurence; basically obtaining another function with the upper limit as the independent variable.
syms x z
y(x) = x^2+x+1;
i1 = int(y,x,0,x)
i2 = int(y,x,0,z)
Maybe common, but often misleading from my experience.
Especially if you want to define a function of the upper limit:
F = @(x)integral(@(x)x.^2,0,x)
It works, but it's quite confusing in my opinion.
Dyuman Joshi
el 26 de Ag. de 2023
I'd say rather confusing than misleading.
What you have wrote is the numerical version of the symbolic integration; idk what's your point with that but it does work.
Respuesta aceptada
Más respuestas (1)
Star Strider
el 26 de Ag. de 2023
0 votos
‘How can I fix this?’
Be certain that tthe expression matches the symbolic expression in the figure. (It currently does not.) Then, be sure that the parentheses enclose the correct sub-expressions and the entire expression since you are taking the square root of all of it.
1 comentario
Walter Roberson
el 26 de Ag. de 2023
f=inline('sqrt(1+((66*x)^2/((1.2*x^2)+3))','x')
% 1 2 34 3 45 4 32 1
... should be 0 at the end of the line.
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





