Function with multiple inputs to function with vector input

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

For clarity, the original answer only deals with 2d vectors, but I may not know the size of mine.
Please show the function.

댓글을 달려면 로그인하십시오.

 채택된 답변

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 11월 3일

답변:

2022년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by