Clear Filters
Clear Filters

Creater a vector front a signal data in specific time intervals

1 view (last 30 days)
I have a equations systems in simulink, that give the direfential equations solutions
In specific times of simulation, for example at 10, 20, 30.. [x1 x2 x3] until the 1000000 and thus,
I need one of these signals in a vector that I can access to compute the diference beetwem samples during the entirely simulation.
For example at 20 seconds i need to know what is x2-x1..
thanks guys,,,,

Answers (1)

Samay Sagar
Samay Sagar on 1 Mar 2024
In Simulink, the "To Workspace" block offers a convenient way to export the output of your simulation directly to the MATLAB workspace. Subsequently, you can use the output in the workspace to access values of signals at specific timestamps for further computation.
Here is a step-by-step guide to achieve this:
  • Add a "To Workspace" block for each signal you want to save (x1, x2, x3, etc.) and connect it to its respective signal.
  • Configure the "To Workspace" block to have a desired variable name (like x1, x2, x3, etc.) and set the sample time (e.g., 10 for sampling every 10 seconds).
  • The default output type of "To Workspace" block is "Timeseries". You can change it to "Array" for ease of use. After running the simulation, you can access the data as "out.x1" and use it for further computation. Assuming that the sample time for the signals is 10 s, you can access the data at time 20 s as "out.x1(3)".
You can read more about the "To Workspace" block here:

Categories

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