- https://www.mathworks.com/help/matlab/ref/datetime.html
- https://www.mathworks.com/help/matlab/date-and-time-operations.html
- https://www.mathworks.com/help/matlab/matlab_prog/other-matlab-functions-supporting-date-and-time-arrays.html
How to finding GAPS in satellite access times.
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
Appreciate any help on how to find gaps in satellite access. The attached picture shows Iridium satellite accesses to a radio near Dulles during 1 day. You can see there are many overlapping accesses. I am trying to find any periods of time that do not have access (any time gaps in coverage). I do have Aerospace Toolbox which quickly calculates all the access intervals.
My question is a may be a more complex verion of this Q&A:
I have tried several plotting approaches but not luck yet. The plot function needed seems like a combination of "stairs" and many, superimposed "fplot" intervals; however fplot intervals do not seem to accept datetime input (the attached shows an attempt to fplot just one access interval).
Thanks in advance.
-Mike
댓글 수: 0
채택된 답변
sai charan sampara
2023년 11월 27일
Hello Michael,
I understand that you are trying to find intervals in which the variable “AccessTrue” is zero when the data contains overlapping intervals.
You can achieve this by using the plot function which works on the “datetime” data type. This can be done by creating a table that contains two columns. One column has set of timestamps that range from “00:00:00” to the last available end time, here it is “00:28:00”. The step duration can be anything of your choice. I have taken 1 minute in this case. The second value can be a logical variable that marks if there is access at that time. This column is initially populated with all zeros and individual row values can be set to one based on the durations where the “AccessTrue” variable is true. It can be done as follows:
%Example data with random values
StartTime=[datetime(2023,11,22,00,00,00);datetime(2023,11,22,00,00,00);datetime(2023,11,22,00,02,00);
datetime(2023,11,22,00,05,00);datetime(2023,11,22,00,10,00);datetime(2023,11,22,00,12,00);
datetime(2023,11,22,00,14,00);datetime(2023,11,22,00,17,00);datetime(2023,11,22,00,21,00)];
EndTime=[datetime(2023,11,22,00,07,00);datetime(2023,11,22,00,02,00);datetime(2023,11,22,00,07,00);
datetime(2023,11,22,00,16,00);datetime(2023,11,22,00,21,00);datetime(2023,11,22,00,20,00);
datetime(2023,11,22,00,25,00);datetime(2023,11,22,00,24,00);datetime(2023,11,22,00,28,00)];
AccessTrue=[1;0;1;0;1;0;0;1;0];
tab=table(StartTime,EndTime,AccessTrue,VariableNames=["StartTime","EndTime","AccessTrue"])
xInterval=[tab.StartTime,tab.EndTime];
access=xInterval(tab.AccessTrue==1,:);
st=[];
for i=0:28
st=[st;datetime(2023,11,22,00,i,00)];
end
access_available=zeros(size(st));
for i=1:length(access)
idx1=find(st==access(i,1),1);
idx2=find(st==access(i,2),1);
access_available(idx1:idx2)=1;
end
stem(st,access_available,"o");
You can refer to the below documentation to learn more about “datetime” data type:
추가 답변 (1개)
Peter Perkins
2023년 11월 27일
There are ways to do this without loops, but the most straight-forward way (assuming the data are sorted by start time) is brute force, something like this:
StartTime = datetime(2023,11,22,0,[0,1,4,5,10,12,14,17,21]',0);
StopTime = datetime(2023,11,22,0,[1,2,11,16,21,20,25,24,28]',0);
Dur = StopTime - StartTime;
t = table(StartTime,StopTime,Dur)
for i = height(t):-1:2
upper = max(t.StopTime(1:i-1));
if t.StartTime(i) <= upper
t.StopTime(i-1) = max(t.StopTime(i),upper);
t(i,:) = [];
t.Dur(i-1) = t.StopTime(i-1) - t.StartTime(i-1);
end
t
end
In your data, IIUC, you had no gaps, so I changed them a bit. now you just need
gaps = table(t.StopTime(1:end-1),t.StartTime(2:end),t.StartTime(2:end)-t.StopTime(1:end-1),VariableNames=["GapStart" "GapStop" "GapDur"])
참고 항목
카테고리
Help Center 및 File Exchange에서 Reference Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!