Find higher value with respect to time from a table?

2 visualizzazioni (ultimi 30 giorni)
With repect to time, i need higher value from the attached table.

Risposta accettata

William Rose
William Rose il 3 Set 2023
Modificato: William Rose il 3 Set 2023
[Edit: add code to display satellite at maxAz and satellite at maxEl.)
I understand now that you wish to find the max azimuth and max elevation within a specified time window. You can do it as follows:
T=readtable('data139a.txt'); % read tabular data from file
dt=datetime(T.(1),'InputFormat','yyyy/MM/dd')+T.(2); % make a datetime vector
% Combine datetime vector with the other columns to make a timetable.
TT=timetable(dt,T.(3),T.(4),T.(5),T.(6),T.(7)); % make a timetable
% Extract all rows within specified time range:
dt1=datetime('19-May-2022 12:00:00'); % dt1=start datetime
dt1s=string(dt1,'HH:mm:ss'); % string for dt1
dt2=datetime('19-May-2022 12:00:30'); % dt2=end datetime
dt2s=string(dt2,'HH:mm:ss'); % string for dt2
TTsmall=TT(dt>=dt1 & dt<dt2,:); % timetable with dt1<=datetime<dt2
% Find the max Az and max EL, in the specified time range
[maxAZ,maxAZidx]=max(TTsmall.Var2);
[maxEL,maxELidx]=max(TTsmall.Var3);
% Use maxAZidx or maxELidx to find other properties associated with the
% maximum, such as satellite name, SNR at max El, etc.
% Display results
fprintf('Total table rows: %d.\n',height(TT)); ...
fprintf('%d table rows have %s<=datetime<%s.\n',height(TTsmall),dt1s,dt2s);...
fprintf('%s<=time<%s:\n',dt1s,dt2s); ...
fprintf('Max AZ=%.1f, satellite %s\n',maxAZ,string(TTsmall.Var1(maxAZidx))); ...
fprintf('Max EL=%.1f, satellite %s\n',maxEL,string(TTsmall.Var1(maxELidx)))
Total table rows: 8346.
3 table rows have 12:00:00<=datetime<12:00:30.
12:00:00<=time<12:00:30:
Max AZ=249.1, satellite G10
Max EL=20.3, satellite G10
The code above finds the max azimuth and max elevation within a specfied time window, and displays the results. There are other ways to do it, which would have fewer lines of code.
Good luck.
  10 Commenti
SOMNATH MAHATO
SOMNATH MAHATO il 5 Set 2023
Thank you for your continous support and help.

Accedi per commentare.

Più risposte (2)

Seth Furman
Seth Furman il 13 Set 2023
Convert data into an easier to read format
!unzip 139.zip
Archive: 139.zip inflating: 139.txt
!head 139.txt
% TIME (GPST) SAT AZ(deg) EL(deg) SNR(dBHz) L1 MP(m) 2022/05/19 00:34:30.0 G01 146.7 15.6 28.50 0.0000 2022/05/19 00:39:00.0 G01 144.9 16.4 31.31 0.0000 2022/05/19 00:40:00.0 G01 144.4 16.6 31.81 0.0000 2022/05/19 00:43:30.0 G01 143.0 17.2 32.44 0.0000 2022/05/19 00:44:00.0 G01 142.8 17.3 34.13 0.3673 2022/05/19 00:44:30.0 G01 142.6 17.4 31.69 0.4631 2022/05/19 00:45:00.0 G01 142.4 17.5 32.88 1.2921 2022/05/19 00:45:30.0 G01 142.2 17.6 32.06 -0.1025 2022/05/19 00:46:00.0 G01 142.0 17.7 30.66 1.2019
!sed -i 's/ */,/g' 139.txt
!sed -i 's/EL(deg) SNR(dBHz)/EL(deg),SNR(dBHz)/g' 139.txt
!head 139.txt
% TIME (GPST),SAT,AZ(deg),EL(deg),SNR(dBHz),L1 MP(m) 2022/05/19 00:34:30.0,G01,146.7,15.6,28.50,0.0000 2022/05/19 00:39:00.0,G01,144.9,16.4,31.31,0.0000 2022/05/19 00:40:00.0,G01,144.4,16.6,31.81,0.0000 2022/05/19 00:43:30.0,G01,143.0,17.2,32.44,0.0000 2022/05/19 00:44:00.0,G01,142.8,17.3,34.13,0.3673 2022/05/19 00:44:30.0,G01,142.6,17.4,31.69,0.4631 2022/05/19 00:45:00.0,G01,142.4,17.5,32.88,1.2921 2022/05/19 00:45:30.0,G01,142.2,17.6,32.06,-0.1025 2022/05/19 00:46:00.0,G01,142.0,17.7,30.66,1.2019
Read data into a timetable
opts = detectImportOptions("139.txt",ReadVariableNames=true,NumHeaderLines=0,VariableNamingRule="preserve",TextType="string");
opts = setvaropts(opts,"% TIME (GPST)",Type="datetime",InputFormat="uuuu/MM/dd HH:mm:ss.S");
tt = readtimetable("139.txt",opts)
tt = 104002×5 timetable
% TIME (GPST) SAT AZ(deg) EL(deg) SNR(dBHz) L1 MP(m) _____________________ _____ _______ _______ _________ ________ 2022/05/19 00:34:30.0 "G01" 146.7 15.6 28.5 0 2022/05/19 00:39:00.0 "G01" 144.9 16.4 31.31 0 2022/05/19 00:40:00.0 "G01" 144.4 16.6 31.81 0 2022/05/19 00:43:30.0 "G01" 143 17.2 32.44 0 2022/05/19 00:44:00.0 "G01" 142.8 17.3 34.13 0.3673 2022/05/19 00:44:30.0 "G01" 142.6 17.4 31.69 0.4631 2022/05/19 00:45:00.0 "G01" 142.4 17.5 32.88 1.2921 2022/05/19 00:45:30.0 "G01" 142.2 17.6 32.06 -0.1025 2022/05/19 00:46:00.0 "G01" 142 17.7 30.66 1.2019 2022/05/19 00:46:30.0 "G01" 141.8 17.8 32.03 -0.2771 2022/05/19 00:47:00.0 "G01" 141.6 17.9 32.06 -0.8351 2022/05/19 00:47:30.0 "G01" 141.4 18 31.38 -0.3719 2022/05/19 00:48:00.0 "G01" 141.2 18.1 33.31 -0.1552 2022/05/19 00:48:30.0 "G01" 141 18.2 33.38 0.7502 2022/05/19 00:49:00.0 "G01" 140.8 18.3 35.44 0.311 2022/05/19 00:49:30.0 "G01" 140.6 18.4 33.53 0.0172
Find the maximum elevation angle for each row time using groupsummary
groupsummary(tt,"% TIME (GPST)","max","EL(deg)")
ans = 2880×3 table
% TIME (GPST) GroupCount max_EL(deg) _____________________ __________ ___________ 2022/05/19 00:00:00.0 34 74.5 2022/05/19 00:00:30.0 35 74.7 2022/05/19 00:01:00.0 34 74.9 2022/05/19 00:01:30.0 34 75 2022/05/19 00:02:00.0 35 75.2 2022/05/19 00:02:30.0 35 75.3 2022/05/19 00:03:00.0 34 75.5 2022/05/19 00:03:30.0 35 75.7 2022/05/19 00:04:00.0 35 75.8 2022/05/19 00:04:30.0 35 76 2022/05/19 00:05:00.0 34 76.1 2022/05/19 00:05:30.0 35 76.3 2022/05/19 00:06:00.0 33 76.4 2022/05/19 00:06:30.0 34 76.6 2022/05/19 00:07:00.0 34 76.7 2022/05/19 00:07:30.0 34 76.9

William Rose
William Rose il 31 Ago 2023
Please explain exactly what you want to do in more detail. Provide an example of code you have tried that did not work.
Your file has 104,002 rows of data, which are observations of about 113 satellites.* The data is sorted by satellite and then by time. I have attached a shorter file with data from 10 satellites, to demonstrate code. Column 1=date, column 2=time of day. The observation times vary for different satelites. Some times are repeated many times through the table. All observations are on the same date.
Combine the date and time columns, to make a datetime array.
T=readtable('data139a.txt');
dt1=datetime(T.(1),'InputFormat','yyyy/MM/dd')+T.(2); % make a datetime vector
Combine the datetime array with the other columns to make a timetable.
TT=timetable(dt1,T.(3),T.(4),T.(5),T.(6),T.(7)); % make a timetable
Extract all rows that have a time greater than a specified time:
dtref=datetime('19-May-2022 11:59:59'); % dtref=reference datetime
TTpm=TT(dt1>dtref,:); % timetable with all times greater than dtref
To make a timetable containing the data for just one satellite (satellite G01, in this example), do this:
TTg01=TT(strcmp(TT.(1),'G01'),:); % timetable for satellite G01
*Satellites in file 139.txt: G01-G32, R01-R15, R17-R18, R20-R24, E01-E05, E07-E15, E18-E21, E24-E27, E30-E31, E33-E34, E36, J02-J04, J07, C19-C46.
  4 Commenti
SOMNATH MAHATO
SOMNATH MAHATO il 3 Set 2023
Dear Rose, I don't want get each satellite maximum elevation angle. I just want maximum elevation angle of a particular time.
SOMNATH MAHATO
SOMNATH MAHATO il 3 Set 2023
For example, 00:00:00 time maximum elevation angle among all the satellite data present.

Accedi per commentare.

Categorie

Scopri di più su CubeSat and Satellites in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by