From workspace in realtime

조회 수: 11 (최근 30일)
Hristo Alexiev
Hristo Alexiev 2011년 2월 28일
Hi.Can somebody tell me, how I can run a simulink block diagram in realtime, which only read data from some variable from Matlab workspace. And which block I have to use???
  댓글 수: 1
Vieniava
Vieniava 2011년 2월 28일
Quite interesting question (voted up)

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

채택된 답변

Paulo Silva
Paulo Silva 2011년 2월 28일
Try this with the Matlab Fcn and a Display (or scope)
Matlab Fcn (evalin('caller','MyVar'))-------->Display
or just
Matlab Fcn (MyVar)-------->Display
Now go to your command line and execute MyVar=0, run the simulation with Simulation time Inf, open look at the display value so you can watch the values changing. Keep watching the display while you change the value of MyVar, it does change in real time (or almost). You can use other variable name than MyVar, just change the code inside the Matlab Fcn.
This is just one of the possible solutions.
Here's another but I won't recommend it, to test it do a model with a constant connected to one display, save it and start the simulation with final time Inf.
In one m file run this code:
for MyVar=1:10
set_param('ModelName/Constant','Value',num2str(MyVar))
pause(1);
end
The simulink display will count from 1 to 10 :)
  댓글 수: 2
Vieniava
Vieniava 2011년 2월 28일
very nice evalin() usage
Paulo Silva
Paulo Silva 2011년 2월 28일
The only bad part is that it doesn't do anything, I just tried without it and worked lol silly me :(

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

추가 답변 (1개)

Hristo Alexiev
Hristo Alexiev 2011년 2월 28일
Thank you very much. I tried these approaches but the first didn't work. "Error: Real-Time Workshop Error in block: "untitled/MATLAB Fcn", block type "MATLABFcn": Not yet supported by Real-Time Workshop" The second approach is perfect and work flawlessly :)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by