How to transfer a function_handle vector to another function in matlab?

% I know I can pass a function handle as a parameter directly to another function Like this form below
f(@func)
% Now I want to pass a one-dimensional function handle vector directly
% what is the best way for me to achieve this?
vector_func=[@func1,@func2,@func3]
f(vector_func)
%I've tried using cell to store function handles, but it throws an error
vec = cell(2);
cell(1) = @func %it will throw an error say cannot convert from function_handle to cell

 採用された回答

Walter Roberson
Walter Roberson 2023 年 2 月 12 日
vector_func = {@func1,@func2,@func3};

1 件のコメント

钦豪
钦豪 2023 年 2 月 12 日
Yes, your suggestion is valid, I just tried it and found that cell reports an error because I was confusing cell() and cell{}.
Thanks for your help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2022b

質問済み:

2023 年 2 月 12 日

コメント済み:

2023 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by