필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to find maximums in matrix

조회 수: 1 (최근 30일)
Fateme Jalali
Fateme Jalali 2016년 2월 22일
댓글: Guillaume 2016년 2월 22일
Hello.I have this matrix A=[116 3;107 6;114 6;119 6;117 9;120 9;108 15 ;113 18;115 18;112 21;111 24].I want to detect local maximums from second column and where local max happened that row should be kept in a new matrix.here (112 21) & (111 24) should be saved in matrix B.i want to do this with for loop and max function.can any one help me plz?
%if true
local_max_maatrix=zeros(size(A,1),2)
local_max_maatrix(end,1)=A(end,1)
local_max_maatrix(end,2)=A(end,2)
threshold_max=3;
for eee=2:size(A,1);
[CC,II] = max(A(eee,2))
if CC-A(eee-1)>threshold_max;
local_max_maatrix(ee,1)=A(ee,1);
local_max_maatrix(ee,2)=A(ee,2);
A(II,:)=[]
end
end
%end
  댓글 수: 2
Stephen23
Stephen23 2016년 2월 22일
Duplicate:
Please do not post duplicate question: you can simply edit or comment your original question.
Guillaume
Guillaume 2016년 2월 22일
What is your definition of a local maximum? In your example matrix, 21 is not a local maximum under any established definition of the term.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by