How to get the corresponding value
86 ビュー (過去 30 日間)
古いコメントを表示
I have a data set I I need to find the first maximum value of R1 and its corresponding T and R2 value , that is
11 14:15 213
I have written a code for max of R1
G=input(:,2);
R1=max(G)
I am getting R1 as 11 but I need to get the corresponding T and R2 as well.
Can anyone help.
Thanks in Advance
The data set is given below.
T R1 R2
0000 1 241
0015 0 351
0030 0 312
0045 0 289
0100 0 288
0115 1 269
0130 0 258
0145 0 258
0200 0 258
0215 0 258
0230 0 258
0245 0 258
0300 0 258
0315 0 258
0330 0 258
0345 0 258
0400 0 258
0415 0 258
0430 0 245
0445 0 241
0500 0 241
0515 0 241
0530 0 241
0545 0 241
0600 0 241
0615 0 241
0630 0 241
0645 0 241
0700 0 241
0715 0 241
0730 0 241
0745 0 241
0800 0 241
0815 1 268
0830 3 128
0845 3 187
0900 3 262
0915 3 163
0930 6 112
0945 6 77
1000 4 72
1015 4 165
1030 8 148
1045 8 173
1100 6 149
1115 6 152
1130 6 127
1145 8 121
1200 8 136
1215 6 127
1230 6 105
1245 8 149
1300 6 204
1315 8 141
1330 6 165
1345 6 90
1400 8 145
1415 11 213
1430 8 149
1445 8 112
1500 8 173
1515 9 48
1530 9 190
1545 6 104
1600 4 201
1615 4 141
1630 6 118
1645 6 100
1700 4 148
1715 4 111
1730 6 90
1745 4 96
1800 0 146
1815 11 135
1830 3 96
1845 6 35
1900 4 122
1915 3 115
1930 4 43
1945 3 66
2000 3 124
2015 1 50
2030 0 19
2045 3 142
2100 3 28
2115 3 118
2130 3 231
2145 3 117
2200 1 86
2215 3 124
2230 4 125
2245 0 9
2300 1 141
2315 0 18
2330 1 29
2345 0 15
1 件のコメント
madhan ravi
2019 年 3 月 11 日
m(find(m(:,2)==max(m(:,2)),1,'first'),[1 3]) % where m is your matrix
%% T--------^ ^----R2
Hi, My input file name is input.txt, instead of m should I use input?
m=table2array(readtable('input.txt'));
Hi, I have number of data sets (date wise) results, Now the data set has an extra column (first column, is date, which I have converted to numbers) I have tried with 'unique' command for date to find max R1 and corresponidng T and R2, but I am not getting proper results. Sample code is attached.
d = input(:,1); %Date
dtm = input(:,2); % Time
u = unique(d);
for k=1:I
n=find(u==d(k));
M45=input(find(input(u(k)),8)==max(input(u(k)),8)),2,'first',[2:7])
end
here
Column 1 date in number format
Column 2 is T
Column 8 is R1,
Column 7 is R2,
回答 (1 件)
KSSV
2019 年 3 月 11 日
Read about max ..it gives you index of maximum value also.
Let A be your m*3 array.
[val,idx] = max(A(:,2)) ; % say you want maximum of second column in A
iwant = A(idx,:)
3 件のコメント
KSSV
2019 年 3 月 11 日
YOu have date in hand.......get days from it......run a loop and pick the values and get the max.
参考
カテゴリ
Help Center および File Exchange で Argument Definitions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!