How do I find the two smallest values in varargin?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Harold Meggs
am 24 Apr. 2015
Beantwortet: David Sanchez
am 24 Apr. 2015
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 Kommentare
Akzeptierte Antwort
David Sanchez
am 24 Apr. 2015
function out = two_lowest_values(varargin)
a = sort(cell2mat(varargin));
out = a(1)*a(2);
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!