フィルターのクリア

Operator '+' is not supported for operands of type 'function_handle'.

4 ビュー (過去 30 日間)
JICHAO ZHANG
JICHAO ZHANG 2023 年 6 月 21 日
回答済み: 埃博拉酱 2023 年 6 月 26 日
I have two function handle,such as g=@(x)x+a,f=@(y)y+b
why not do '+'
h=g+f
for example
for t=1:10
h(0)=g;
h=g+t.*f
end

回答 (2 件)

Matt J
Matt J 2023 年 6 月 21 日
編集済み: Matt J 2023 年 6 月 21 日
It's a bad idea (i.e. very inefficient) to add two functions together, however, the proper way would be as follows:
g=@(x)x+1;
f=@(y)y+2;
h=@(z) g(z)+f(z);
h(10)
ans = 23
  3 件のコメント
Matt J
Matt J 2023 年 6 月 21 日
h=@(x,y) g(x)+f(y);
Dyuman Joshi
Dyuman Joshi 2023 年 6 月 26 日
@JICHAO ZHANG please check Matt's response to your comment.

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


埃博拉酱
埃博拉酱 2023 年 6 月 26 日
Only symbolic functions can be added directly. You may need to refer to Symbolic Math Toolbox.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by