Hello,
for the attached table we would like to find the index of the max point of the variable NE8 within the range of (200,400) applied on the variable GDALT. This might be a simpel task and I am complicating it but if anyone can help.

 채택된 답변

Githin George
Githin George 2022년 7월 25일
편집: Githin George 2022년 7월 25일

0 개 추천

Hi Salma,
My understanding is that for rows having GDALT in range 200-400 you would like to find the row where NE8 is maximum.
Please see if this code helps
txt = readtable("table.txt");
% I'm adding an Index Column, in case you specifically want the index
txt.INDEX = (1:height(txt))';
subTable = txt(txt.GDALT >=200 & txt.GDALT <=400, :);
% getting idx in the subtable using max function
[~,idx] = max(subTable.NE8,[],'omitnan');
% this row contains the required result. You can use the index from this
% row.
result = subTable(idx,:)
Hope this helps.

댓글 수: 3

Salma fathi
Salma fathi 2022년 7월 25일
편집: Salma fathi 2022년 7월 25일
Thank you for the quick reply. what you have proposed is giving me the index in the table "Subtable", whereas it would be much helpful for me if I can get the index of the max point in the original table. Is that possible?
And I am getting this error for the last line
Unrecognized function or variable 'mat'.
Error in PeakConstruction (line 218)
result = mat(idx,:);
Githin George
Githin George 2022년 7월 25일
편집: Githin George 2022년 7월 25일
I've corrected the mistake in last line. The last element in result will contain the 'index' from original column.
Thank you so much this helped me alot and solved my problem. Appreciate the help.

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

추가 답변 (1개)

KSSV
KSSV 2022년 7월 25일
T =readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1075965/table.txt') ;
NE8 = T.NE8 ;
idx = NE8>200 & NE8<400 ;
val = max(NE8(idx))
val = 0×1 empty double column vector
It looks like there is no data in the given range.

카테고리

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

제품

릴리스

R2021b

태그

질문:

2022년 7월 25일

댓글:

2022년 7월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by