How to trace back a subfunction

1 次查看(过去 30 天)
zhe li
zhe li 2013-2-1
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

回答(1 个)

Thorsten
Thorsten 2013-2-1
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

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by