Reading a wire value from Simulink into the Command Window or GUIDE

조회 수: 7(최근 30일)
River Rock
River Rock 2012년 8월 20일
편집: John Kelly 2016년 7월 12일
I want to read the values that passes through a wire in my Simulink model.
This value should be displayed in a text field on a MATLAB GUI (it's the water level in a tank that is acquired every 100 ms).
I found out about get_param instruction, but until now I only managed to get the values from constants and transfer functions; example: get_param('main/Constant','Value') ; get_param('main/Transfer Function','Denominator').
How do I address a wire and its property list (value)?
The data is generated by an OPC Read block, passing through a subsystem using an Out port.

추가 답변(1개)

River Rock
River Rock 2012년 8월 21일
Thanks for your answer; I was able to get the data from the filter's output
data=get_param('main/level/level_filter','RuntimeObject'); lvl = data.OutputPort(1).Data;
It works ok by request
How can I display this data cyclically in a Static Text field on a GUI ? Is there some callback that runs periodically ( and the sample time can be specified) ?
  댓글 수: 4
River Rock
River Rock 2012년 8월 23일
I found a workaround yesterday. But your solution looks more elegant, I had to use global variables.
Thanks for your great support, the problem is solved.

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

Community Treasure Hunt

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

Start Hunting!

Translated by