How do I find the two smallest values in varargin?
조회 수: 1 (최근 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에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!