Simulations with undefined variables

조회 수: 1 (최근 30일)
Federico Avino
Federico Avino 2021년 3월 15일
답변: Arthi Sathyamurthi 2021년 3월 25일
Hi, I have got a problem to which I can't find any solution on the net.
I'm building a Simscape/Simulink model loading some parameters from the workspace, and i should perform the following task: doing some control actions comparing the last values of certain variables from a previous simulation, with the initial values of the same variables in the next simulation. In practice it is to simulate if something happened to the physical system while the microcontroller was not active: so comparing last values from the sensors before the shutdown and first values from the sensors at the startup.
I was considering to export the last values of the variables to the workspace with the block To Workspace, and, in the next simulation, to send them in the simulink model as constants, but in this way at the first execution the constants would be undefined. Any suggested solutions?
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2021년 3월 15일
no other way but providing your best educated guess values and loading those values as part of your simulation setup

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

답변 (1개)

Arthi Sathyamurthi
Arthi Sathyamurthi 2021년 3월 25일
You can save the variable to the base workspace by using the To Workspace block or by using the Data import/export option in the configuration settings. And then save it as a mat file by modelling callbacks. You can directly use the To File block and directly save it as a mat file in the current folder. After following any of the above steps you can import the particular value from the mat file by using any of the callbacks as per your workflow and then use it in the program during your next simulation.

카테고리

Help CenterFile Exchange에서 Data Logging에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by