フィルターのクリア

Integrating without using the symbolic toolbox

24 ビュー (過去 30 日間)
Opariuc Andrei
Opariuc Andrei 2020 年 12 月 14 日
コメント済み: Opariuc Andrei 2020 年 12 月 14 日
syms x
f=log(45.*sin(x.^2) + cos(x)); % initial function
g=sqrt(1+diff(f).^2); % requirement step 1
h=int(g,0,pi/2) ;% requirement final step
instead of int i want to use " integral " and solve numerically ,if i remove the syms and introduce @(x) then i won't get a displayed result
and the result of final step while using the syms method is :
int(((sin(x) - 90*x*cos(x^2))^2/(45*sin(x^2) + cos(x))^2 + 1)^(1/2), x, 0, pi/2)
x belongs (0,pi/2)
How can i get rid of syms ?

採用された回答

John D'Errico
John D'Errico 2020 年 12 月 14 日
編集済み: John D'Errico 2020 年 12 月 14 日
This is an arc length integral. Apparently you wish to compute the length of that curve in the plane, with x going from 0 to pi/2. As a numerical integral, this is easy.
syms x
f=log(45.*sin(x.^2) + cos(x)); % initial function
fplot(f,[0,pi/2])
g=sqrt(1+diff(f).^2); % requirement step 1
gfun = matlabFunction(g);
First, it alway makes sense to plot everything, before you just throw it into any general tool.
fplot(g,[0,pi/2])
I don't epect that arc length integral has an exact solution. I might also be slightly worried about what seems to be a singularity at 0, though an integration tool should survive that. You can use vpaintegral, if you wish to stay in the symbolic domain.
vpaintegral(g,[0,pi/2])
ans = 
4.73865
Or you can use integral.
integral(gfun,0,pi/2)
ans = 4.7386
Which seems to agree.
And, since I have a tool on the file exchange that can compute the arclength of a curve, I might try this:
ffun = matlabFunction(f);
xint = linspace(0,pi/2);
arclength(xint,ffun(xint),'spline')
ans =
4.7383
which also seems to agree pretty well.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by