integrate with the upper limit is a function

19 ビュー (過去 30 日間)
L.GREEN
L.GREEN 2024 年 7 月 31 日
移動済み: Star Strider 2024 年 8 月 4 日
Hello!
How to integrate a function on Matlab with the upper limit is a function, for exemple the following integral:
i tried this code:
U= vpa(int(f,s,0,t^2))
but it returns int(f,s,0,t^2)!!
is there any method to do it?
  9 件のコメント
Walter Roberson
Walter Roberson 2024 年 7 月 31 日
移動済み: Star Strider 2024 年 8 月 4 日
If you have working with a mix of scalar constants and scalar symbolic variables, then you can use ^ and / instead of .^ and ./ . You only need .^ and ./ if you are working with non-scalar values.
syms s t
f1 = sin(0.008414709848078965066525023216303*exp(-2*s^(1/2)) + 0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303) + 1
f1 = 
f2 = sin(0.008414709848078965066525023216303*exp(-2*s.^(1/2)) + 0.00008414709848078965066525023216303*cos(s).^2 + 0.008414709848078965066525023216303) + 1
f2 = 
isAlways(f1 == f2)
ans = logical
1
Torsten
Torsten 2024 年 8 月 1 日
移動済み: Star Strider 2024 年 8 月 4 日
The inconvient of the intergal function is that we need to use '.^ 'and/or './'
If you have a symbolic function and want to convert it to a function that can be used together with "integral", use "matlabFunction". Here, you will also get .^, ./ and .* operators.
Another way is to use the 'ArrayValues',true option for "integral" that passes one value for s to the function at a time. The disadvantage is that this option might slow down the integration:
f = @(s) sin(0.008414709848078965066525023216303*exp(-2*s^(1/2)) + 0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303) + 1;
F = @(t) integral(f,0,t^2,'ArrayValued',1);
tnum = 0:0.1:5;
Fnum = arrayfun(@(t)F(t),tnum);
plot(tnum,Fnum)
grid on

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by