Need helps for data disappear after running "sim"

Hello everyone, I am a simulink learner. I have one problem with date save related with "sim". Thank you for helping. Problem statement: When running the "sim('model')", the variables names of the simulink model can be seen in the matlab base Workspace. But when "sim" command is completed and continues to the following codes, all those mdl variables disappear from the workspace, even the "save to space" ports are set in simulink model. I do not how to solve this problem. Thanks for any suggestion and help!

 채택된 답변

Andreas Goser
Andreas Goser 2011년 8월 5일

1 개 추천

Try this
[x,y]=sim('vdp');
Use the SIM command with return variables like described in the doc

댓글 수: 3

J T
J T 2011년 8월 5일
Hi Andreas, many thanks for your helps. I am working on this, and still having some problem, could you give some suggestion and help? Thank you.
I tried to solve this problem. I found there was some differences between my model and the example in help documents.
The variables which are expected to return in my model are design variables-parameters in masked subsystem, like resistance parameters in circuit simulated. The examples in help document specify the way of how to set and return those in "Configuration parameter".
The other thing I am using the Matlab 2008a version, I tried to find "Return as single object" on the Data Import/Export pane , but it is not there. I am wondering whether it is related to the version. If it is, can I have substitutive solution?
Thank for helping
J T
J T 2011년 8월 5일
I think I should discribe the problem statement in this way: In my simulink model A, there are several masked subsytems (a,b,c.. ), in which the parameters are defined ({x1} for a; {x2} for b;...).
The output port "Out1" of model A denotes my object result, but it should be a iterative result.
I have to set a loop run for model A based on intial [{x1}, {x2}, {x3}... ]. The "Out1" should be returned to main arithmetical program, and the main program will assign updated {x1'} for masked system a; {x2'} for masked system b;...
I am using the "sim" in the circumstant, and met all these problems.
Thank you. I am not sure which commands are supposed to use. Or there is more suitable command? Thank you.
I am afraid your descriptions confuse me. The SIM command is used when you want to control simulations through MATLAB, e.g. for parameter studies. Your description is not clear to me, but it sounds like it is a valid reason to work with SIM.
Now to the masked subsystems. I do not see a reason why this matters.
About the returned data. When you use "To Workspace" blocks, the data will be in the base workspace. Maybe your MATLAB Code is a function and not a script and thus, the return data is in the function's workspace.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Subsystems에 대해 자세히 알아보기

질문:

J T
2011년 8월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by