Simulink orbit propagator: How do I pause and access data at each time step?

6 views (last 30 days)
Hi All;
As you know Simulink has a wonderful high precision orbit propagator block. This block is pretty much a closed (black) box such that you give all the inputs and start the simulation (i.e. propagtion) between time steps t_start upto t_end. It then outputs all the results as a batch after the simulation so the user can access position and velocity data.
Instead of running this script in one single batch, what I want to do is the following:
  • 1) propagate the orbit at every time step (say every 1 second)
  • 2) then get the position and velocity vector to MATLAB
  • 3) do something with that R and V vectors
  • 4) then go back to step 1 and propagate for next time step.
I tried different methods to do this. I tried pausing the sim or calling the entire simulator giving a delta simulation time of 1 second but it does not really work.
Is there anyway which I can do what I just explained.
Many thanks for responses ?
Gökhan

Accepted Answer

Govind KM
Govind KM on 13 Sep 2024
As I understand, at every simulation time step, you want to save the position and velocity outputs of the “Orbit Propagator Numerical (high precision)” block and perform some operations with this data before proceeding to the next time step. This can be done by stepping through the simulation using controls in the Simulink Toolstrip. Steps for this are as follows:
  • In the “Data Import/Export” section of Model Configuration Parameters, make sure the “Output” and “Single simulation output” options are enabled. Set the output “Format” to “Structure”.
  • Give labels to the position and velocity output signals (say “x” and “v”) and connect them to outport blocks.
  • In the Simulink Toolstrip, on the “Simulation” tab, click “Step Forward”. The simulation will start and pause after calculating values for the first simulation time step.
  • The values of the output data at this time step will now be saved to the MATLAB workspace in the “Simulink.SimulationOutput” object. Access and perform operations with the data as required in a MATLAB script:
%Assuming output variables have default names out and yout
%Assuming position output is connected to outport 1
pos=out.yout.signals(1);
%Assuming velocity output is connected to outport 2
vel=out.yout.signals(2);
%Get data at current time step
curpos=pos.values(end,:);
curvel=vel.values(end,:);
%Process current position and velocity data as required
  • Click “Step Forward” to proceed to the next time step and repeat the process.
You can refer to this documentation for more information on Stepping through simulations:
This process can be automated in a MATLAB script using a “Simulation” object as mentioned in the following documentation:
Hope this addresses your query.
  1 Comment
Gökhan
Gökhan on 23 Sep 2024
Using the links you posted I have now started to use the methods prescribed in the link. Many thanks for your prompt response. It seems to have solved my issues.
Regards
Gökhan

Sign in to comment.

More Answers (1)

Gökhan
Gökhan on 23 Sep 2024
Using the links you posted I have now started to use the methods prescribed in the link. Many thanks for your prompt response. It seems to have solved my issues.
Regards
Gökhan

Categories

Find more on General Applications 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!