MATLAB: How do i find the smallest positive number

MATLABmatrixmatrix manipulationminiminpivot columnpivot elementpivot rowtableau

I am making a function that finds the Pivot Element of a Tableau. However everything seems to works fine beside Line 13 [ValR,Row]=min(PivotR./tableau(2:a,b)). ValR will only be the smallest number in the given range, not just positive. min function gives the smallest number(including negative). Is there something i can use instead of min function?
function pivotElement = getPivot(tableau)
pivotElement = 0
pivotCol = 0
[a,b]=size(tableau)
FirstRow=tableau(1,1:b-1)
[ValC,Column]= min(FirstRow)
if(ValC< 0)
pivotCol = Column
end;
pivotRow=0
PivotR=tableau(2:a,pivotCol)
[ValR,Row]=min(PivotR./tableau(2:a,b))
if(ValR > 0)
pivotRow = Row
end;
if ((pivotRow~=0)&&(pivotCol==0))
pivotElement = 0
end
if ((pivotRow==0)&&(pivotCol~=0))
pivotElement = 1
end
if ((pivotRow~=0)&&(pivotCol~=0))
pivotElement = [pivotRow;pivotCol]
end
end

Best Answer

There is no built-in command for that.
function [mins, idxes] = minpositive(Array, varargin)
Array(Array<=0) = nan;
[mins, idxes] = min(Array, varargin{:});
Related Question