returning output of nested function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John
el 9 de Dic. de 2013
Editada: Wayne King
el 9 de Dic. de 2013
Hi there,
I have a function nested inside another function. How can I get the main function to return the output of the nested function so that I can see it in the workspace? I want to the "fval" as an output below.
Thank you
function [output1,output2] = OptimiseEnergy(input1,input2,input3,input4)
% do stuff with inputs 1-4
[x, fval] = linprog(obj_vec, a, b,[],[],lb,ub,x0,options)
end
0 comentarios
Respuesta aceptada
Wayne King
el 9 de Dic. de 2013
Editada: Wayne King
el 9 de Dic. de 2013
You have to assign fval to one of the outputs of the top-level function.
Or add fval as an output of the top-level function -- OptimiseEnergy
For example:
function [x,y,z] = playfunc(a,b)
% a and b are equal size vectors
x = a+b;
y = a-b;
z = conv(x,y);
end
conv.m is called inside playfunc.m and the output of conv is returned from playfunc.m
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Function Creation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!