Creater a vector front a signal data in specific time intervals

2 次查看(过去 30 天)
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,,,,

回答(1 个)

Samay Sagar
Samay Sagar 2024-3-1
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:

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by