Azzera filtri
Azzera filtri

How do I call to function from other function?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

KSSV
KSSV il 9 Ago 2020
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

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by