필터 지우기
필터 지우기

How to store data while simulating a model?

조회 수: 4 (최근 30일)
roro6992
roro6992 2014년 6월 11일
댓글: roro6992 2014년 6월 14일
Hi everyone, i have written a s function in which i want to store the data generated during one simulation loop and use that data in the next simulation loop. How can i do this? Is there any way of storing the data in a matrix and retrieving that data matrix in the next simulation step?? Please help. Thanks!

답변 (3개)

Abhishek M
Abhishek M 2014년 6월 11일

David Sanchez
David Sanchez 2014년 6월 11일
You need to add two blocks to your model.
1) to save data, ad "To Workspace" block. This will send and save data into the workspace
2) to get data, add "From Workspace" block.This will read data stored in the workspace.
Properly done, you can link data from one simulation to the next.
Read the documentation for examples on deeper detail
  댓글 수: 1
roro6992
roro6992 2014년 6월 11일
Actually I have written a matlab level 1 S function and i wonder how can i store the various data generated in the update stage of the S function and use it in the next time step of the simulation of the model containing the s function. Is there any way? Please suggest.

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


Kaustubha Govind
Kaustubha Govind 2014년 6월 13일
You can use states in an S-function to store data from previous time step(s). Note that Level-1 S-functions are no longer supported, and only exist for backwards compatibility reasons. Please convert it to a Level-2 MATLAB S-function of possible. Type sfcndemo_sfundsc2 at the MATLAB prompt to open a Level-1 S-function example that uses a state to store the value of the previous input (thus acting as a Unit Delay). Type msfcndemo_sfundsc2 to see the Level-2 S-function version of the same algorithm.
  댓글 수: 1
roro6992
roro6992 2014년 6월 14일
Thanks. I have converted it to a level 2 matlab s function and used the Dwork vector to store the variable data. I needed seven dwork vectors. But while i am simulating the model including the s func block...the simulation is taking too long to respond and its showing the word 'Initializing' in the bottom left corner and after sometime matlab stops responding. Why is this happening? Would u please check my code? and tell whats wrong? The code is attached.

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

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by