Borrar filtros
Borrar filtros

How do I call to function from other function?

1 visualización (últimos 30 días)
Jimmy cho
Jimmy cho el 9 de Ag. de 2020
Respondida: KSSV el 9 de Ag. de 2020
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.

Respuesta aceptada

KSSV
KSSV el 9 de Ag. de 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

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by