필터 지우기
필터 지우기

How can I stream data form MATLAB to Simulink in real time?

조회 수: 15 (최근 30일)
Michal
Michal 2012년 11월 22일
댓글: Larasmoyo Nugroho 2017년 9월 12일
I was trying to use "From Workspace" block but, it gathers the value only once at the beginning of the simulation. I cannot just run a m-code script, save data and then transfer it to Simulink becouse both together need to work with real time vision system. How can I solve that problem?
EDIT:
Thank you very much for your answers. I have tried the solution with S-function that you gave to me, and also by set_param() command, but unfortunately it doesn't work for me how I would like to. The main problem is that there is a need to stop MATLAB script for a moment to let Simulink gather a data, which means I have to use pause() command inside of main for loop of my MATLAB script. If I don't do this, Simulink waits with executing a model at t=0. The problem is that a minimum time for which the m-code script can be stopped by pause() command is approximately 0.0156 s. which is to long for me. That script realize object tracking on the video images from webcam, so such a long pauses causes the fps decrease.
So, my next question, more precise is: Is there any way to stream data from running MATLAB script to running Simulink model without or with just very small delay?

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 11월 26일
You can either use the block RuntimeObject as Vishal suggested, or write a MATLAB S-function.
  댓글 수: 1
Larasmoyo Nugroho
Larasmoyo Nugroho 2017년 9월 12일
check my work.. https://www.mathworks.com/matlabcentral/fileexchange/64394-how-to-stream-data-from-m-file-to-simulink-block

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

추가 답변 (1개)

Vishal Rane
Vishal Rane 2012년 11월 26일
Explore the 'RuntimeObject' property of non-virtual blocks.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by