Borrar filtros
Borrar filtros

Converting simulink blocks to code for a GUI?

4 visualizaciones (últimos 30 días)
Justin Liang
Justin Liang el 14 de Mayo de 2013
I would like to create a GUI in MATLAB that has two sliders that can be used to adjust the value a and b. I know I can get the GUI to open simulink and have simulink do this and then packet the information using UDP as shown in the following image:
However, I would prefer to be able to convert these simulink blocks to code in the GUI slider. More specifically, I am interested in coding the packet output block so the GUI button can send the information. Does anyone know how to do this?

Respuestas (2)

cr
cr el 14 de Mayo de 2013
You can use set command for callbacks of GUI sliders with handles of the constant blocks to change the block parameter values. Not sure what the packet output block is, but if you are able to "send the information" from simulink, then the same can be done via GUI too using handle to the block. For more info, see gcs, gcb, set & get. You may want to read the section on programmatically using simulink models in documentation.
  1 comentario
Justin Liang
Justin Liang el 19 de Mayo de 2013
Editada: Justin Liang el 19 de Mayo de 2013
The packet block sends unformatted binary data. Here is the full simulink model:
So what I do here is use Packet Output to send a double value using UDP. The Packet Input block receives it and sends it to the Scope and in that Scope you will see a horizontal line with a y value equal to the double value in the Constant block.
HOWEVER, for me, I need to code both the Constant and Packet Output blocks in MATLAB for the GUI. For example, in my GUI I might have a slider that changes the value in the Constant block and also sends the information to Packet Input. I should be able to easily test this by removing the Constant and Packet Output blocks and then sliding the sliders on the GUI. This should change the graph in Scope.
Also, what documentation can I read the section on programmatically using simulink models?

Iniciar sesión para comentar.


Kaustubha Govind
Kaustubha Govind el 20 de Mayo de 2013
Since you'd like to execute the GUI as if it were a block, it might be best to create a custom block that opens up and reads from a GUI during simulation, and computes its outputs based on actions on the GUI. Please look into MATAB S-functions.
  1 comentario
Justin Liang
Justin Liang el 25 de Mayo de 2013
Thank you for the reply, with your method Simulink has to be running right? Because for my application I would like to have the GUI run everything and send the packets.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by