how to write a code in which the output of a one function will be out put to an other function.?

2 visualizzazioni (ultimi 30 giorni)
I have created 5 functions in different m files. v=[1,2,4,3,5]% if the function execution order, in this case, the output of function will be the input to the function 2 and output of the function 2 will be input to the function 4 and function 4 output will be input to the function 3 and so on, in the end, the final output

Risposte (1)

Stephen23
Stephen23 il 14 Ago 2018
Modificato: Stephen23 il 14 Ago 2018
This is easy, assuming that each function has just one input and output. Try this:
C = {@fun1,@fun2,@fun3,@fun4,@fun5}; % cell array of function handles.
val = []; % initial value.
for k = [1,2,4,3,5] % the order to call the functions in.
val = C{k}(val);
end

Categorie

Scopri di più su Multidimensional Arrays 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