Minimum positiver real number.

Hi, How do you find the minimum poositive real number for example d=[73 -1.07 1.08 0.01]
i want 0.01 min(d) gives -1.07

 Accepted Answer

Use logical indexing first:
>> d = [73 -1.07 1.08 0.01];
>> min(d(d>0))
ans =
0.01

3 Comments

thanks
Thinking of it is there a way to find a second highest number like for this case 1.08
Try sorting:
d = [73 -1.07 1.08 0.01];
sorted_d = sort(d(d>0), 'descend')
secondHighest = sorted_d(2)

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 18 May 2016

Commented:

on 19 May 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!