Assigning indexes in an array and finding max values in a selected range

If we have X = time series data and signal in a 8000x 2 array (Matlab 2017b). The first column is time and the second column is signal of light absorbance. How can we find a maximum value in the selected range say from row 4000:5000 of the second column? Additionally, I would to like generate another column within X containing the index of each entry so that it becomes 8000x3 array. Thanks.

 채택된 답변

Assuming that X is a timeseries object (and not a Simulink time series):
rstart = 4000; rend = 5000;
[maxabs, maxidx] = max(X.Data(rstart:rend,2));
maxloc = rstart + maxidx - 1;
data_there = X.Data(maxloc,:);
It is not clear to me what the third column would be an index of?

댓글 수: 4

Thanks, I was looking for an index of the maximum value so that I can visually see where it is between 4000:5000. maxloc = rstart + maxidx - 1;
Is it correct that you want a new third column that is the index of each row so that when you find out the maxloc you can find the row visually in the table?

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2017b

질문:

FW
2019년 4월 26일

댓글:

2019년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by