Sort satellites in Satellite Communication Toolbox
2 views (last 30 days)
Show older comments
I take satellite information from TLE file, which contains information about 500+ satellites.
Can I show in satelliteScenarioViewer only satellites with Orbital Position > 50?
How can I do it?
0 Comments
Accepted Answer
akshatsood
on 9 Jan 2024
Edited: akshatsood
on 11 Jan 2024
I understand that you seek guidance in shortlisting the satellites based on a particular condition i.e. orbital inclination greater than 20 degrees. To display only these satellites in the Satellite Scenario Viewer, it requires parsing the TLE file to extract orbital parameters, identify the satellites that satisfy the inclination criteria, and then selectively visualize those specific satellites in the scenario viewer.
Following Step 2, where I have applied filters to isolate satellites that meet the specific criteria, I proceed to Step 4. In this step, I process each of the shortlisted satellites. For each one, I determine its precise location within the input file (`file.txt`), then proceed to record not only the satellite's name but also the subsequent two lines of data into the output file (`filteredSatellites.txt`). This output file is then passed on to the "scenarioViewer" function for visualiztion purpose.
Here is a MATLAB code snippet that demonstrates the process
% Step 1: read the TLE file and parse it
tleData = tleread('file.txt');
% Step 2: filter satellites based on inclination
selectedSatellites = {};
for i = 1:length(tleData)
inclination = tleData(i).Inclination;
if inclination > 20
selectedSatellites{end+1} = tleData(i);
end
end
% Step 3: create a satellite scenario
startTime = datetime(2023, 1, 1, 0, 0, 0);
stopTime = startTime + days(1);
sampleTime = 60; % in seconds
sc = satelliteScenario(startTime, stopTime, sampleTime);
% Step 4: write selected satellites to a txt file
outputFile = "filteredSatellites.txt";
out = fopen(outputFile, 'w');
for i = 1:length(selectedSatellites)
% extract name for the satellite
satelliteName = selectedSatellites{i}.Name;
% writeNextTwoLines locates the position of selectedSatellite
% within the input file 'file.txt'
writeNextTwoLines = false;
linesToWrite = 2;
f = fopen('file.txt', 'r');
while ~feof(f)
currLine = fgets(f);
if contains(currLine, satelliteName)
fprintf(out, '%s\n', satelliteName);
writeNextTwoLines = true;
continue
end
% selected satellite is found then, and the next two
% lines are written to the output file
if writeNextTwoLines & linesToWrite
fprintf(out, '%s', currLine);
linesToWrite = linesToWrite - 1;
end
end
fclose(f);
end
fclose(out);
sat = satellite(sc, 'filteredSatellites.txt');
% Step 5: visualization
viewer = satelliteScenarioViewer(sc);
Have a look at the following references for a better understanding
I hope this helps.
10 Comments
akshatsood
on 11 Jan 2024
Edited: akshatsood
on 11 Jan 2024
This will be your 'file.txt'. Whatever is the name at your side for this file, do replace it and proceed with the approach.
TDRS 5
1 21639U 91054B 24010.68729772 .00000098 00000+0 00000+0 0 9990
2 21639 14.1828 0.2823 0025271 355.3430 194.2333 1.00273517118799
IUS R/B(1)
1 21640U 91054C 24010.66407335 .00014000 00000+0 29686-2 0 9990
2 21640 26.3989 148.1621 6726049 148.4213 280.2536 3.00852110312745
IUS R/B(2)
1 21641U 91054D 24010.09670545 .00000106 00000+0 00000+0 0 9991
2 21641 14.7247 340.3842 0034282 326.2724 55.5420 1.00175445 38458
More Answers (0)
See Also
Categories
Find more on CubeSat and Satellites in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!