find array/matrix max value and position

3 ビュー (過去 30 日間)
Francisco
Francisco 2012 年 1 月 25 日
Hello
I have a matrix 1 x 130049 double and i want to find the max value and his position
What i have written so far:
m=max(p);
l=length(p); % length= 130049
for i=1:l
if p(s)== m
position=s;
end
end
The variable 'position' give me numbers that don't have anithing to do with what want. If someonecan help me...plz Thanks

回答 (1 件)

Oleg Komarov
Oleg Komarov 2012 年 1 月 25 日
Look at the second output argument of the max function.
[m,idx] = max(p)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by