Function with multiple inputs to function with vector input

조회 수: 6 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by