MATLAB Answers

iB
0

How to find n number of low value's position or column number from a cell ?

Asked by iB
on 7 Nov 2019 at 14:57
Latest activity Commented on by dpb
on 11 Nov 2019 at 13:43
I have cell sized 1x45, containing values like [0.22 0.12 0.001 0.01 ... ] now I want to find the column numbers of 5 or any no. of lowest values. Thank you

  0 Comments

Sign in to comment.

1 Answer

Answer by dpb
on 7 Nov 2019 at 15:06

NtoFind=5;
[Mn,iMn]=mink(X,NtoFind);

  4 Comments

Show 1 older comment
Your example, while saying "cell" showed an ordinary array in brackets so I presumed that was what actually was. Dereference the cell array with "the curlies" -- see the documentation in the Getting Started section on accessing data in cell arrays to get the basics of syntax down.
[Mn,iMn]=mink(X,NtoFind{:});
I thik my matlab virsion is the problem, mine is R2015a. That is why 'mink' is not working.
Indeed, mink wasn't introduced until R2017b, I think...
The easiest coding way then is to use sort with the optional returned indices vector and select the first N

Sign in to comment.