MATLAB: Getting minimum value from an array

findminimum

I want to get min of A= [0, 20, 15]. Actualy I want to find the minimum excluding the zero. So in the example my answer would be 15 not zero. Finaly I want to get the index of the minimum value. What I have done so far looks like:
for i=1:size(A)
if A(i)~=0
[index,c]=find(min(A));
end
end
but it is not giving me the results I want.

Best Answer

try
c=min(A(A~=0))
idx=find(A==c)