I am struggling with integrating a function.
古いコメントを表示
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 件のコメント
Torsten
2023 年 8 月 26 日
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
2023 年 8 月 26 日
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.
採用された回答
その他の回答 (1 件)
Star Strider
2023 年 8 月 26 日
0 投票
‘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 件のコメント
Walter Roberson
2023 年 8 月 26 日
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.
カテゴリ
ヘルプ センター および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





