Function with multiple inputs to function with vector input

6 views (last 30 days)
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?

Accepted Answer

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

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!