How can I quickly pass the output of a Simulink block to a GUI?

I currently have a simulink model in which a custom matlab function block performs some signal processing on a frame of data and then saves the results to the workspace with every iteration with the "assignin" command.
I then have a GUI, which I made in GUIDE, that uses a timer object to repeatedly pull this data from the workspace and display it in a variety of ways with the "evalin" command.
This works fine, but it is a little slow. I know I can read object parameters of a simulink block with my gui directly with the "get_param" command.
Is it aso possible to read the output of blocks in this way?
That is, can I employ a more direct or continuous method to read the output of the simulink blocks into my GUI without reading/writing to the workspace?
Thanks!
-Will

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 4월 30일
get_param allows to read block parameters, the block output is not a parameter

댓글 수: 3

Correct, the output is not a parameter. I should have been more clear. Here's what I'm asking:
I know get_param will allow me to read a parameter of a simulink block from the workspace. Is there a command with which one can read the output of a block from the workspace?
I.E. -- does some sort of get_output function exist?
Thanks for your response, Azzi.
you can save your output to workspace(the fastest way) or to a file,
I found a solution, or a work-around, that operates faster than the assignin/evalin method however I have to close/reopen the model every time I stop it. I simply save the output of the function to the UserData parameter of the block. Now I can access it with get_param.
In case anyone needs to do something similar, here is a simple example:
function y = f(x)
coder.extrinsic('set_param');
%coder.extrinsic tells the compiler to ignore "set_param"
%because it isn't supported.
y = x*5;
set_param('ModelName/BlockName','UserData',y);
Now, while this model is running, from a GUI(or from the workspace) one can execute the following command:
get_param('ModelName/BlockName','UserData')
However, now I have a new question:
When I stop the model and try to run it again I get this error: Object parameter contains an invalid handle. Does anyone know what causes this?
Thanks.

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

Rey
Rey 2013년 5월 3일

0 개 추천

Have you tried using an event listener? Check out the link below and do some googling, I guess it is what you are looking for:

카테고리

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

질문:

2013년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by