hi, my array=[ 1 2 4 5 16 18 21 28 36 38..............], i need to find max value within every 10 numbers,(i.e, my answers=[5 18 28 38...............]).

조회 수: 1 (최근 30일)
i dont know to explain clearly in english, sorry.

채택된 답변

Walter Roberson
Walter Roberson 2016년 11월 3일
I suspect that you want a sliding maximum. One way to do that is
max( buffer(data, 10))
Another way is to use the image processing toolbox morphological routines. I seem to recall that dilation corresponds to max but I could be mistaken.
You could also loop.
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 11월 3일
Thanks, Guillaume, I went looking for such a function but could not find it; it is not cross-linked in the moving average routines.
kaavya subramani
kaavya subramani 2016년 11월 4일
S sir, u r right, i have already used variable named as "max", actually my code is too long, thatsy it takes long time to identify the errror

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

추가 답변 (1개)

KSSV
KSSV 2016년 11월 3일
data = rand(1,100) ; % some random data
data1 = reshape(data,10,[]) ; % reshape to matrix with 10 rows
val = max(data1) ; % get maximum
  댓글 수: 10
kaavya subramani
kaavya subramani 2016년 11월 3일
Ok sir, anyway thanks for ur time, i try my whole code in some other matlab version
Walter Roberson
Walter Roberson 2016년 11월 3일
That error about subscript indices tells us that you created a variable named max. If you have a variable named max then you can not call the MATLAB max() routine in the same scope.

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

카테고리

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