How to show values used in min() function?
显示 更早的评论
If you have:
R = [0:0.01:40];
L = 800./R - 1./4*pi*R ;
cost = 30*(2*L + 4*R)+40*(pi*R) ;
min(cost)
How do I extract the values of R and L used in finding the min(cost) ?
回答(2 个)
mincost=min(cost);
idx=(cost==mincost);
Rmin=R(idx);
Lmin=L(idx);
dpb
2016-9-6
[mnCost mnIdx]=min(cost);
>> sprintf('Min R,L,cost: %.2f,%.4f = %.2f',R(mnIdx),L(mnIdx),mnCost)
ans =
Min R,L,cost: 15.55,39.2340 = 6174.11
类别
在 帮助中心 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!