Find higher value with respect to time from a table?
2 views (last 30 days)
Show older comments
SOMNATH MAHATO
on 31 Aug 2023
Answered: Seth Furman
on 13 Sep 2023
With repect to time, i need higher value from the attached table.
0 Comments
Accepted Answer
William Rose
on 3 Sep 2023
Edited: William Rose
on 3 Sep 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)))
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 Comments
More Answers (2)
Seth Furman
on 13 Sep 2023
Convert data into an easier to read format
!unzip 139.zip
!head 139.txt
!sed -i 's/ */,/g' 139.txt
!sed -i 's/EL(deg) SNR(dBHz)/EL(deg),SNR(dBHz)/g' 139.txt
!head 139.txt
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)
Find the maximum elevation angle for each row time using groupsummary
groupsummary(tt,"% TIME (GPST)","max","EL(deg)")
0 Comments
William Rose
on 31 Aug 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 Comments
See Also
Categories
Find more on CubeSat and Satellites in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!