Azzera filtri
Azzera filtri

How to trace back a subfunction

3 visualizzazioni (ultimi 30 giorni)
zhe li
zhe li il 1 Feb 2013
Dear All,
Thanks for your time.
I am trying to find the best solution for an application, then trace back the subfunction which provide the calculation data and show which the subfunction is. e.g.
function [a]=b()
for i=1:2
c{1}=d()
c{2}=e()
a=20+c
end
f=min(a)
subfunction 1 which is
function [c]=d()
c=2
end
subfunction 2 which is
function [c]=e()
c=5
end
I would want to show which subfunction is used once achieving the minimum result f, is it function d or function b?
Thank you very much for your help in advance.
Zhe Li

Risposte (1)

Thorsten
Thorsten il 1 Feb 2013
Why don't you use something like
solution1 = 20 + d();
solution2 = 20 + e();
if solution1 < solution2
f = solution1;
disp('min result achieved with subfunction 1')
else
f = solution2;
disp('min result achieved with subfunction 2')
end

Community Treasure Hunt

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

Start Hunting!

Translated by