change variable in function_handle

6 ビュー (過去 30 日間)
saeed rezaei
saeed rezaei 2021 年 5 月 19 日
コメント済み: saeed rezaei 2021 年 5 月 19 日
hello all,
i wanna to change x in f=@(x)sinx to x+2 so that we have g=(x)sin(x+2)
how can i derive g from f in matlab?
thanks alot

採用された回答

the cyclist
the cyclist 2021 年 5 月 19 日
I think this is what you mean?
% Define f
f=@(x) sin(x);
% Derive g from f
g = @(x) f(x+2);
% Show that it gives expected result
f(2)
ans = 0.9093
g(0)
ans = 0.9093
  1 件のコメント
saeed rezaei
saeed rezaei 2021 年 5 月 19 日
thanks alot

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

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 19 日
f=@(x)sin(x)
g = @(x)f(x+2)
Good luck
  1 件のコメント
saeed rezaei
saeed rezaei 2021 年 5 月 19 日
thank you

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

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by