How do I call to function from other function?

조회 수: 2 (최근 30일)
Jimmy cho
Jimmy cho 2020년 8월 9일
답변: KSSV 2020년 8월 9일
Hi guys, Im building two function with I call one of them from another function, so how can I call the other function in matlab? just write its name where I want to implement it?
I mean lets assume Im building two functions one called func1, the other function called func2 .. I want to call in the func1 to the func2 so what should I write inside the implemenation of func1 .. just func2 and then matlab compiler will call to the other implementation of func2? thanks alot.

채택된 답변

KSSV
KSSV 2020년 8월 9일
You need to save both the function files in the same folder and yes call the other function in the required function. It is very simple. Check the below example.
function val = thesum(a,b)
val = a+b ;
end
Now call the above function inisde another function.
function val = theproduct(a,b)
c = thesum(a,b) ;
val = c*a*b ;
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by