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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by