フィルターのクリア

How do I multiply a given function handle with the independent variable?

2 ビュー (過去 30 日間)
Saurabh Madankar
Saurabh Madankar 2023 年 4 月 3 日
回答済み: Steven Lord 2023 年 4 月 3 日
I have pre-defined n number of function handles f_{i} which are functions of t for i = 1 to n. How do I define a new function g_{i} = t.f_{i} and then evaluate the integral of each g_{i} from t=0 to 1?

採用された回答

Steven Lord
Steven Lord 2023 年 4 月 3 日
f = @sin;
g = @(t) t.*f(t);
format longg
[3*sin(3); g(3)] % Spot check by evaluating the function at t = 3
ans = 2×1
0.423360024179602 0.423360024179602
Now you can use g like any other function handle in functions like integral.
numericAnswer = integral(g, 0, 2*pi)
numericAnswer =
-6.28318530717959
syms x
symbolicAnswer = int(x.*sin(x), 0, 2*pi) % or
symbolicAnswer = 
symbolicAnswer = int(g(x), 0, 2*pi)
symbolicAnswer = 
[numericAnswer; double(symbolicAnswer)]
ans = 2×1
-6.28318530717959 -6.28318530717959

その他の回答 (1 件)

埃博拉酱
埃博拉酱 2023 年 4 月 3 日
Use symfun and int in Symbolic Math Toolbox if you want to do integrals.

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by