- To Workspace block - https://www.mathworks.com/help/simulink/slref/toworkspace.html
- Run Simulations programmatically - https://www.mathworks.com/help/simulink/ug/using-the-sim-command.html
How to write To Workspace data to a workspace
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to be able to run Simulink from a program, write To Workspace data to the workspace in real time, and use the workspace values in calculations within the program.
Please answer. It would be appreciated if you could include the programme.
댓글 수: 0
답변 (1개)
ag
2024년 12월 27일
Hi A,
I understand that you want to run a Simulink model using a MATLAB script, with the objective of storing the simulation output in the MATLAB workspace and subsequently utilizing these values for further calculations.
To achieve this, you can employ the "To Workspace" block in Simulink, which allows you to write data directly to the MATLAB workspace.
Below is a self-explanatory script that demonstrates how you can execute the model from the script and use the output data for calculations:
% Define the Simulink model name
modelName = 'your_model_name';
% Simulate the model
out = sim(modelName);
% Extract the output from the "To Workspace" block
toWksData = out.simout;
% Perform calculations with the obtained data
calculatedData = 2 * toWksData;
For more details, please refer to the following MathWorks documentations:
Hope this helps!
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!