Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

A good way to publish simulink values to GUI from a running model?

Asked by Bjoern on 5 Apr 2012

I currently can affect a running model from my GUI, both start/pause/stop and update values that are inputs to the current model. I do this via workspace variables to constant blocks using set_param(...'update').

Now I need to show values from my running model in my GUI but I'm not sure of how I would do that? My plan was to use a 1 second timer and then read out signal values but I'm not sure of how to do that. Please let me know if you have a good way!!

Any thoughts are appreciated, thanks! //bjoern

1 Comment

Bjoern on 5 Apr 2012

(To clarify: I do know how to create the 1sec timer but not how to read out the signal value during runtime)

Bjoern

Products

2 Answers

Answer by Guy Rouleau on 5 Apr 2012
Accepted answer

This is a good approach.

However with just that, your GUI will need a mechanism to poke at the model to get the data.

I would combine that with an event listener:

http://www.mathworks.com/help/toolbox/simulink/slref/add_exec_event_listener.html

That way, the event listener can send the data from the runtime object to your GUI automatically every time the block output value is updated.

1 Comment

Craig on 14 Sep 2012

How can this be done to the outputs about a subsystem (rather than specific internal blocks )? (in 2007b).

Guy Rouleau
Answer by Bjoern on 5 Apr 2012

I just found a possible solution, something like:

  • BlockH = get_param('TheBlockOfInterest','RuntimeObject');
  • TheValue=BlockH.OutputPort(PortNr).Data;
  • DisplayValueInGui(TheValue);

Is this approach recommended? Please any comments are appreciated! Thanks!

0 Comments

Bjoern

Contact us