finding the maximum of values after and before a specific value

hello, I have a doubt.Is it possible to find out the maximum values before and after the ith element in an array?

댓글 수: 2

Adam
Adam 2017년 12월 19일
편집: Adam 2017년 12월 19일
yes
max( array( ( i + 1 ):end ) )
max( 1:( i - 1 ) )

댓글을 달려면 로그인하십시오.

 채택된 답변

Birdman
Birdman 2017년 12월 19일
One approach:
a=randi([1 10],1,10);
ind=4;%4th element in a vector is chosen
a1=a(1:ind-1);
a2=a(ind+1,end);
max(a1)
max(a2)

댓글 수: 1

Thank you. If anybody is using this please note that
a2=a(ind+1:end);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

태그

질문:

2017년 12월 19일

댓글:

2017년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by