Azzera filtri
Azzera filtri

How to run GUI in Matlab browser and script at the same time

1 visualizzazione (ultimi 30 giorni)
I'm building a demonstrator for a project of mine. I have the background script working fine and the GUI also works by itself.
The problem I have is that the script needs to work constantly in the background to process data as it comes in, and the GUI should display the data in realtime. I build the GUI with html, so I have a few scripts for the GUI that write the data into the html files as needed.
The problem I found today is that I cannot execute the background script and the GUI at the same time in the client. I have been using global variables to shift data between various subscripts and the GUI scripts, which won't work if I run one or the other on a worker.
My question has two parts: One, is it possible to run both scripts on the client, i.e. that the GUI can interrupt the background script for short periods (that is acceptable)?
Two, if that is not possible, how do I make the data accessible for the GUI? I thought about using files and such but the problem there is, what happens if the GUI script tries to read a file while the background script tries to write?
Thanks for the help.

Risposte (1)

Walter Roberson
Walter Roberson il 13 Ott 2015
Write the background script as a callback for data being received by whatever kind of input you are using (just about everything except audiorecorder() has data ready callbacks.) The graphics runs off callbacks too. For automatic updates of the graphics you can call them from the data callback or you can call them from a timer.
I don't have a link to the FAQ about sharing variables handy on my phone.
You might want to use a ring buffer
  3 Commenti
Walter Roberson
Walter Roberson il 19 Ott 2015
Do not have the background script loop. Have it fetch only once and then return. And start a timer that invokes the script.
I am not clear on when the graphics needs to be updated. You started by saying it had to be updated in real time but now you say it is there for visual appeal.
Daniel il 20 Ott 2015
Found a different solution but thanks for your help.

Accedi per commentare.


Community Treasure Hunt

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

Start Hunting!

Translated by