フィルターのクリア

converting function handle into an operator

1 回表示 (過去 30 日間)
Kamlesh Pawar
Kamlesh Pawar 2011 年 8 月 25 日
Hi all,
i have a function handle as F =@ (x) func(x)
i want to convert this function handle into an multiplication operator means if i type F*x then it should be equivalent to calling the function as func(x). Can anyone have the solution for this ?

採用された回答

Walter Roberson
Walter Roberson 2011 年 8 月 25 日
You could create an "operator" class, and make F a member of that class... e.g., through syntax such as
F = operator_handle(@(x) func(x));
where operator_handle is the constructor for the class.
Once you have done that, writing F*x would be the same as writing mtimes(F,x) . You would then define a mtimes() method within your class that extracted the function handle from the object and applied it to the data.
(Corrected to "mtimes" instead of "mult" that I had before.)
  1 件のコメント
Kamlesh Pawar
Kamlesh Pawar 2011 年 8 月 26 日
Thanks walter

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by