GUIDE Flow and Functions

I am using GUIDE to create a UI.
How can I create functions that run in the background? I assume the program loops through checking for UI events related to the listed callbacks, however I would also like to have functions that run independently of user interaction.
I only know of the timer object, but I may also like to have functions that are conditionally run etc. or just at a predetermined order in program flow.
Is there any way of doing this without coding the app programatically, as we would like to expedite the GUI by using GUIDE?
Cheers

7 comentarios

Rik
Rik el 15 de Feb. de 2018
So what is it exactly what you want to do? (BTW, I expect that Matlab isn't actively looping over UI elements, but rather uses listeners).
Martin Thompson
Martin Thompson el 15 de Feb. de 2018
I am communicating with a serial port object and am not sure where to put my code in GUIDE. Apparently the opening function executes only once before the GUI opens, which begs the question where do I put my conditional code, serial read functions etc. to run while the GUI is open.
Cheers
Rik
Rik el 15 de Feb. de 2018
GUIDE is not something special, it is just a wrapper which should make GUI design easier. It sounds to me like you don't really need a visual interface at all, so either I don't understand what you want, or you don't understand how GUIDE/Matlab works. What do you mean with conditional code? What should trigger the condition to be checked? When should you serial read function be executed?
I'm sorry, but if I don't understand your problem I can't help you.
Martin Thompson
Martin Thompson el 15 de Feb. de 2018
I don't understand how GUIDE/MATLAB works (in this context, and it's my first time incorporating a GUI into a program).
My intention is to publish the code as a standalone executable. The GUI is for plotting data, some buttons/menus for user input as for filtering, data to be displayed etc.
The serial object will send data and need to receive data (its a microcontroller). The MCU may need to halt execution depending on some of the data received for example. Not to mention when serial data becomes available in the buffer I want to be able to read it and I'm not sure where to put the code to do that.
So I opened GUIDE and am looking at the editor now for the GUIDE code and I see function varargout, the opening function, all my callbacks etc. and cannot figure out where to place the aforementioned functionality which if I were programming in c or such I would put in a continuous loop.
Cheers
Rik
Rik el 15 de Feb. de 2018
I would suggest putting your continuously looping function either somewhere at the end of the starting function, or in callback from a start button. Then try to draw a flowchart of all the things your program needs to do in what order, after that you can much more easily tackle bite-sized problems. Right now your question is probably too big for a single working answer. One of the most important things to learn is to reduce a big problem to solvable smaller problems.
Geoff Hayes
Geoff Hayes el 15 de Feb. de 2018
Editada: Geoff Hayes el 15 de Feb. de 2018
Martin - could you use a timer to communicate with your serial port object? The timer could be started and stopped from within the GUI, and would continuously poll (?) your serial port object for new data. See https://www.mathworks.com/matlabcentral/answers/284202-how-to-plot-a-real-time-signal-with-axes-automatically-updating for an example.
Martin Thompson
Martin Thompson el 15 de Feb. de 2018
Cheers Rik. Hi Geoff, that's a good idea, but I think that the solution lies in using BytesAvailableFcn which generates an event when a certain number of bytes are available on the input buffer. I can then specify the callback function for use with the event.
I am now looking at defining my own events that I can associate with certain callback functions in the opening function of the GUIDE generated code (for conditional executions where there are no predefined event generating functions). However this may require linking to a library or something more complicated, so if you still might know where I could put general code that could be useful.
CHeers

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Environment Customization en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Feb. de 2018

Comentada:

el 15 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by