How to make a function handle of another function handle?

As input for my function file I have a function handle, for example y = @(x)x.^3. In this function file this function is evaluated, however I also want to integrate the absolute value of this function. The MATLAB command integral requires a function handle: integral(@(x)y,LB,UB). How do I take the absolute value of this function handle? I tried: @(x)abs(y), but this didn't work. Also some other things I tried didn't work, except filling in @(x)abs(x.^3), but this is not what I want, because the function handle should remain an input for the function file.

 採用された回答

Alexandra Harkai
Alexandra Harkai 2016 年 10 月 14 日

0 投票

@(x) abs(y(x)) Because yo need variable x to be part of the expression of your new anonymous function. Taking y(x) then take the absolute value of that.

1 件のコメント

Bas Bolk
Bas Bolk 2016 年 10 月 15 日
Ah yes, of course! Thanks a lot!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2016 年 10 月 14 日

コメント済み:

2016 年 10 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by