필터 지우기
필터 지우기

How to run the m-file in an infinite loop. I have to run this for the real time experiment. I have to acquire the process variable into a m-file and run that continuosly to control the porcess. My need is to run m-file in an infinite loop.

조회 수: 5 (최근 30일)
I can send the process variable into the m-file and i can get the solved variable into the workspace. Question is how to run the m-file in infinite loop.
regards

답변 (2개)

Sebastian Castro
Sebastian Castro 2015년 7월 16일
How "real-time" does this have to be? If you're OK using the CPU clock time, I'd recommend using MATLAB timers.
You can configure a timer to run a particular MATLAB function at some rate. Also, once you start a timer it'll keep going unless you stop it.
For example, the following code will run a function someFunction at a fixed rate every 0.1 seconds (assuming that's slow enough to not overrun -- depends on how fast your function is).
t = timer('TimerFcn',@someFunction,'Period',0.1,'ExecutionMode', 'fixedRate');
- Sebastian
  댓글 수: 3
Dr.Thirunavukkarasu Indiran
Dr.Thirunavukkarasu Indiran 2015년 10월 15일
Thanks for your reply. I have developed the Dynamics Matrix Control codes in M-File and its giving exact tracking for the given set point. Now iam trying to implement in real time system. For the physical implementation with the conical tank system, iam using the simulink environment to acquire the signal and to send the control signal from matlab code to the physical conical tank system via simulink. I used the interpreter function file. Since my code has some for loops, it was not executing. Can you guide in this issue.
Sebastian Castro
Sebastian Castro 2015년 10월 15일
Recall that the contents of a Simulink block execute every time the block does; so you want only the control law that's inside the for-loop inside the block.
As far as real-time with Simulink, I'd look at this block to slow down to model to (almost) real-time.
- Sebastian

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


Walter Roberson
Walter Roberson 2015년 7월 16일
while true
... code here
end

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by