필터 지우기
필터 지우기

Passing function with parameters to another function

조회 수: 2 (최근 30일)
Mazin Mustafa
Mazin Mustafa 2017년 10월 17일
댓글: KSSV 2020년 7월 1일
Hi,
I am trying to create a function that accepts another function with its own parameters e.g. Func1(@(x)Func2(x,para1,para2,...etc)) Is this possible in Matlab? If yes, how?
  댓글 수: 2
Mazin Mustafa
Mazin Mustafa 2017년 10월 21일
I actually found the solution for this. just using the function handle inside the body of the function.

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

답변 (1개)

KSSV
KSSV 2017년 10월 17일
f1 = @(x,y) x(y) ;
f2 = @(y) sin(y) ;
f1(f2,pi/2)
  댓글 수: 3
Amjith Shaheer
Amjith Shaheer 2020년 7월 1일

Why do u have to put a dot in x.^2 + a;.I am new to Matlab

KSSV
KSSV 2020년 7월 1일
If x is an array to get element by element square, you have to put . i.e .^

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by