Error loading TLE file into satellite object

8 views (last 30 days)
I'm creating a GPS scenario loading current TLE into the satellite object with following commands:
% Create Scenario
startTime = datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss');
stopTime = startTime;
sampleTime = 1; % secs
sc = satelliteScenario(startTime,stopTime,sampleTime);
% Load TLE
websave('tledata.tle', 'https://celestrak.org/NORAD/elements/gp.php?GROUP=gps-ops&FORMAT=tle');
% Put satellites into the scenario
sats = satellite(sc,'tledata.tle');
But I obtain following error:
Error using satelliteScenario/satellite>throwExceptions
Unable to add satellite to the satelliteScenario.
Error in satelliteScenario/satellite
Caused by:
Incorrect size for expression 'time.fmt': expected [1x0] but found [1x19].
Has anyone an idea on what's going on? TLE file seems to be OK.
  1 Comment
Andrew Mihalik
Andrew Mihalik on 23 Jul 2024
Hello, if we assume I ran the following code:
sc = satelliteScenario;
StartTime_datestring= '2024-07-22 17:52:39'
StopTime_datestring= '2024-08-23 17:52:39'
Can anyone explain why, then, this code executes correctly and without error:
StartTime_datetime=datetime(StartTime_datestring,'InputFormat','yyyy-MM-dd HH:mm:ss');
StopTime_datetime=datetime(StopTime_datestring,'InputFormat','yyyy-MM-dd HH:mm:ss');
sc.StartTime=StartTime_datetime
sc.StopTime=StopTime_datetime
But this code:
StartTime_datetime=datetime(StartTime_datestring,'Format','yyyy-MM-dd HH:mm:ss');
StopTime_datetime=datetime(StopTime_datestring,'Format','yyyy-MM-dd HH:mm:ss');
sc.StartTime=StartTime_datetime
sc.StopTime=StopTime_datetime
creates an error saying Incorrect size for expression 'time.fmt': expected [1x0] but found [1x19].

Sign in to comment.

Accepted Answer

Varun
Varun on 29 Jan 2024
Hi Jose,
Looks like the error is related to the size of the 'time.fmt' field in the TLE file. The expected size is [1x0], but the error indicates that it found [1x19].
I debugged the code and found that the error is occurring due to the first line because of using ‘Format’ name-value pair in the ‘datetime’ function:
startTime = datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss');
To resolve this error, you can simply replace this line with the following line which is independent of ‘Format’ name-value pair:
startTime = datetime('now');
Please refer to the following documentations to learn more:
Hope it helps.
  2 Comments
Andrew Mihalik
Andrew Mihalik on 23 Jul 2024
Hello, if we assume I ran the following code:
sc = satelliteScenario;
StartTime_datestring= '2024-07-22 17:52:39'
StopTime_datestring= '2024-08-23 17:52:39'
Can anyone explain why, then, this code executes correctly and without error:
StartTime_datetime=datetime(StartTime_datestring,'InputFormat','yyyy-MM-dd HH:mm:ss');
StopTime_datetime=datetime(StopTime_datestring,'InputFormat','yyyy-MM-dd HH:mm:ss');
sc.StartTime=StartTime_datetime
sc.StopTime=StopTime_datetime
But this code:
StartTime_datetime=datetime(StartTime_datestring,'Format','yyyy-MM-dd HH:mm:ss');
StopTime_datetime=datetime(StopTime_datestring,'Format','yyyy-MM-dd HH:mm:ss');
sc.StartTime=StartTime_datetime
sc.StopTime=StopTime_datetime
creates an error saying Incorrect size for expression 'time.fmt': expected [1x0] but found [1x19].

Sign in to comment.

More Answers (0)

Categories

Find more on Satellite Mission Analysis in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!