Simulink configuration to save/plot data

6 views (last 30 days)
JB
JB on 21 Jun 2024
Answered: Anushka on 16 Jun 2025
Why does my simulink scope plots data i did not ask for it? Did i mess up some configuration? I don't remember changing anything, but this is the plot i'm getting
this also makes the data i want to save incorrect using To Workspace. Does anyone know what's going on? Thank u so much!
  2 Comments
Aquatris
Aquatris on 21 Jun 2024
what is in the first transfer function and whta is in the second transfer function?
Looks like they are not a single transfer functions but a matrix of transfer functions. You should provide the full file for someone to be more helpful
Francisco J. Triveno Vargas
Hi JB,
  • Initially you can go to configurations and use a fixed step, for example 1/200, also use the runge-kutta algorithm
  • Second, you can use the configurations to save the variables that you want from your sctructure
  • Third, you can use to workspace block, record and save, after that you need to creiate a small script to plot the variables that you needed.
Regards

Sign in to comment.

Answers (1)

Anushka
Anushka on 16 Jun 2025
Hi @JB,
According to my understanding, the issue you are facing is likely because you are feeding a 'Mux' block (which combines multiple signals) into both the 'Scope' and the 'To Workspace' block. When you do this, Simulink logs all the signals in the 'Mux', not just the one you are interested in. This is why you are seeing unexpected plots and incorrect data being saved.
To fix this, use separate lines to tap only the specific signal(s) you want and connect them individually to their own 'To Workspace' blocks. This will ensure only the relevant data is logged and plotted. You can still use the 'Mux' for visualization in the 'Scope' if needed but keep logging separate for clean results. You can do the same by following the below given steps:
  1. Tap off the lines for the signals you need: e.g., just y(t) or u(t).
  2. Add a separate 'To Workspace' block for each signal.
  3. Set the Save format to 'Array' or 'Structure with time' depending on your need.
Hope this helps!

Categories

Find more on View and Analyze Simulation Results 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!