Integration is not evaluated inside a function file

Hi
Could you please help with code below. It is not clear to me why the integration does not evaluated inside the function file. when I used script it is worked but I need to simplified the process by creating the func file to call it at different steps. The integration is identified for the variable (b) as presented in the code below:
function Fg=Fg(a)
syms b;
f_UHM=b/(-0.181363336688152-0.637631218835414*b)+2.64004309728928;
diff_f_UHM=diff(f_UHM)
a1=a-2.5;
FF=diff_f_UHM*asin(b/a1)
q1=int(FF,0,a1)
F=subs(f_UHM,a1)
Fg=F-(2/pi)*q1
end

 採用された回答

Star Strider
Star Strider 2019 年 2 月 18 日

1 投票

In the MATLAB Symbolic Math Toolbox, the correct syntax for your int call would be:
q1 = int(FF,b,0,a1)
However, I do not understand the endis call. Is this MATLAB, or is that a typographical error?

4 件のコメント

Wazy sky
Wazy sky 2019 年 2 月 18 日
編集済み: Wazy sky 2019 年 2 月 18 日
Star Strider
Thanks for your comment.
Yes, endis is a typo. It is just end statment for the function line.
the following line does not yield solution. if you run the code, you will see that the integration equal the same equation with no real integration occured
q1 = int(FF,b,0,a1)
I edited the code in the post as there typos in last line.
Star Strider
Star Strider 2019 年 2 月 18 日
If I run the code and use the vpa function, I get a numeric result:
a = 42; % Supply Scalar Argument
...
q1 = int(FF,b,0,a1)
q1_vpa = vpa(q1)
...
produces:
q1_vpa =
-0.045932121720870913230908902574835
The vpa function will simplify expressions, and if possible, will force a numeric result.
Wazy sky
Wazy sky 2019 年 2 月 18 日
Great! So much appreaciated
Star Strider
Star Strider 2019 年 2 月 18 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by