Get the position of the max and min values of a variables

1 回表示 (過去 30 日間)
flashpode
flashpode 2022 年 2 月 2 日
編集済み: Walter Roberson 2022 年 7 月 31 日
Hi, so I want the position of the maximun values of a variable my code is:
pos = 1:numel(lat1);
b = maxk(lat1,5);
% index = pos(b);
When I use the line of code indez = pos(b) I get the following error:
Array indices must be positive integers or logical values.
I dont get why. Can somebody help me?

採用された回答

Stephen23
Stephen23 2022 年 2 月 2 日
[b,index] = maxk(lat1,5);
% ^^^^^ the second output is the index
  1 件のコメント
flashpode
flashpode 2022 年 2 月 2 日
編集済み: Walter Roberson 2022 年 7 月 31 日
Darn I feel bad cos both answer the question at the same time!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by