필터 지우기
필터 지우기

A way to make the Simulink program run and then perform the calculation

조회 수: 1 (최근 30일)
THANH DAT
THANH DAT 2023년 5월 19일
댓글: Jon 2023년 5월 24일
I want to put this code into matlab Function but this calculation is only done when the program in simulink is finished running. So is there a way to make the Simulink program run and then perform the calculation?

채택된 답변

Jon
Jon 2023년 5월 19일
You can set the model's StopFcn call back for this purpose.
Go to the Modeling tab, model settings, properties,callbacks, and assign your stop function there.
Provide the name of the script or function to be executed in the StopFcn callback property.
Note the script must use values that are assigned in the workspace, so you should provide some to workspace blocks or use other means (assign data logging) to the outputs of interest so they will be in the workspace after the simulation stops.
  댓글 수: 2
THANH DAT
THANH DAT 2023년 5월 23일
Thank you very much, but i can't put this value from Callback function to Constant after Simulation stop. Do you have any suggestion for this?
Jon
Jon 2023년 5월 24일
Sorry I'm not completely clear on what you are trying to do and what problem you are having.
With the StopFcn, shown above, the new value for the variable, Angle, will be assigned in you base workspace after the run is completed. If you run the model again, the new value will be used. If you need to initialize the variable, Angle, for the first time you open and run the model you could do that in a script that you run before running the model. This could also be put into a model Callback function, such as InitFcn

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by