how to find non zero minimum
Show older comments
hi, i have a [8200,1] matrix with zero and positive values. i need to find non zero minimum. please guide me if you can
Accepted Answer
More Answers (2)
Zoltán Csáti
on 4 Oct 2014
Lets suppose your matrix is called A. Then you first select those elements that are non-zero (i.e. positive) and after that use the min function:
min(A(A > 0))
Erick Medina
on 28 Nov 2017
1 vote
Declare a temp_variable which is a copy of your target vector and delete all indexes equal to zero.
temp_vec = vec; temp_vec(temp_vec==0) = []; min(temp_vec)
Categories
Find more on Operators and Elementary Operations 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!