How do I find the two smallest values in varargin?
2 次查看(过去 30 天)
显示 更早的评论
For example, the varargin input is 5,3,6
I want to multiply the the two lowest values, 5*3.
I have tried this:
y=sort (varargin,1, 'ascend');
z=y(:, 1:2);
area= z{1}*z{2};
This is the error I receive:
Error using sort
DIM and MODE arguments not supported for cell arrays.
0 个评论
采纳的回答
David Sanchez
2015-4-24
function out = two_lowest_values(varargin)
a = sort(cell2mat(varargin));
out = a(1)*a(2);
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!