필터 지우기
필터 지우기

Simulink : How can I update the data from Workspace while the simulation is running?

조회 수: 50 (최근 30일)
Hello,
My simulation is writing data in Matlab from Simulink, then I automatically paused it and do some computations on Matlab. After that the Simulink is continued automatically and I want to read the results of the Matlabs computations on Simulink.
The problem is that the box "From Workspace" doesn't update the values while the simulation is running or even paused. Is there a solution for updating the values or no?
Thanks for the help.

채택된 답변

Baptiste
Baptiste 2015년 3월 24일
Problem solved :
I made a matlab function that load a '.mat' file with the variable I want and pass it as an output of my matlab function in Simulink.
  댓글 수: 2
Luis Estrada
Luis Estrada 2015년 3월 30일
편집: Luis Estrada 2015년 3월 30일
Can you publish your solution, I have the same problem, but I dind't unterstand what did you do?
耀资
耀资 2024년 5월 17일
hello,I have the same problem recently, do you still remember how to fix it? If you see this answer, could you please tell me how to do?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Ilham Hardy
Ilham Hardy 2015년 3월 23일
편집: Ilham Hardy 2015년 3월 23일
How do you pause the simulation?
Based on the description on To Workspace this should be possible (updated), see below:
The To Workspace block inputs a signal and writes the signal data to the MATLAB® workspace. During the simulation, the block writes data to an internal buffer. When the simulation is completed or paused , that data is written to the workspace. The block icon shows the name of the array to which the data is written.
  댓글 수: 2
Baptiste
Baptiste 2015년 3월 23일
To pause the simulation, I used an Assertion block with the callback set_param('test','SimulationCommand','pause').
The To Workspace is not the problem, it is when I want to read the data computed from the Workspace that I cannot.
Ilham Hardy
Ilham Hardy 2015년 3월 23일
So To Workspace block does update its value? Did you already confirm that To Workspace values are updated in the base workspace?
If it is confirmed, then on to the next questions:
How or from where do you call ("read the data computed") the variable? Is it from function, script or directly in Matlab Command Window?
Are you aware that matlab "have" several workspace?

댓글을 달려면 로그인하십시오.


Peeyush
Peeyush 2015년 3월 23일
편집: Peeyush 2015년 3월 23일
Hi Baptiste,
This can be done using SET_PARAM command. In Simulink only Tunable Parameters can be changed with SET_PARAM at runtime. You can have a look at the below blog for the description:
You can update work space variables dynamically when a simulation is running. To do this, type:
set_param(bdroot,'SimulationCommand','update')
Regards, Peeyush Pashine Engineer in MathWorks
  댓글 수: 1
Baptiste
Baptiste 2015년 3월 23일
Thanks for the answer, but it seems that I cannot update the variables from the Matlab workspace with set_param.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Prepare Model Inputs and Outputs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by