Error in using find

Hello,
I am using find(a==min(a),1) to find the index of minimum element of "a" which is a row vector. I am looking for the first minimum, in fact. However, I am receiving this error:
??? Subscript indices must either be real positive integers or logicals.
I am really confused since I am using the same syntax in another code and it's working perfectly there. But I can't see what might go wrong here.
Any help would be appreciated. Saeed

 采纳的回答

Did you by any chance assign a variable as min? Because min is a MATLAB function, if you also create a variable, min, (never a good idea), you will get that error. Enter:
>>which min
and see what you get. To demonstrate that error:
min = 2;
a = randn(1,4);
find(a==min(a),1)
You should then clear min

更多回答(1 个)

Saied
Saied 2012-2-10

0 个投票

I had actually defined min as a variable in my code. I changed it and problem is resolved.
Thank you.

类别

在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by