finding the maximum within a specific range
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Githin George
2022 年 7 月 25 日
編集済み: Githin George
2022 年 7 月 25 日
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 件のコメント
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.
その他の回答 (1 件)
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))
It looks like there is no data in the given range.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!