Function with multiple inputs to function with vector input

12 ビュー (過去 30 日間)
Josef Lát
Josef Lát 2022 年 11 月 3 日
回答済み: Fangjun Jiang 2022 年 11 月 3 日
In this answer, I found my problem and a partial answer. However, In my case, I have a
f = @(z1, z2, ..., zn) ...
and I would need to unwrap a vector z = [z1, z2, ..., zn] instead:
f = @(z) ...
How can this be done?
  2 件のコメント
Josef Lát
Josef Lát 2022 年 11 月 3 日
For clarity, the original answer only deals with 2d vectors, but I may not know the size of mine.
Davide Masiello
Davide Masiello 2022 年 11 月 3 日
Please show the function.

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2022 年 11 月 3 日
f=@(z1,z2,z3) z1+z2+z3;
f(1,2,3)
ans = 6
a=1:3;
b=num2cell(a);
f(b{:})
ans = 6

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by