Azzera filtri
Azzera filtri

Plot a figure inside parfeval

17 visualizzazioni (ultimi 30 giorni)
or ohev shalom
or ohev shalom il 31 Lug 2019
Commentato: Walter Roberson il 31 Lug 2019
Hello all,
I've built an app using the AppDesigner and I would like the app to execute different functions according to user's choise (the requests could be at different times). The execution of each function might take time.
I've noticed that if I request an execution of two functions, Matlab HALTS the execution of the first function until the second one is done.
This is probably because there is only one worker to execute everything.
A quick research pointed out I should use parfeval. However, it seems that if function F should plot a figure, it doesnt do so.
I've Managed to verify that function F did ran, I simply saved the workspace inside F.
Any ideas why parfeval won't plot? Or workaround without having to return the figure as output?
Thanks in advance!

Risposta accettata

Walter Roberson
Walter Roberson il 31 Lug 2019
There is only one graphics thread that is connected to the display, and that thread is associated with the client. You can create figures is parallel workers but they will have access to limited graphics facilities, and you would have to save them on the worker.
  2 Commenti
or ohev shalom
or ohev shalom il 31 Lug 2019
I see. So basically is it possible that my app would be able to run functions on several threads without having to control it via parpool?
Walter Roberson
Walter Roberson il 31 Lug 2019
MATLAB is only partly thread-safe and in particular memory allocation and deallocation is not considered thread safe. There are ways that you could invoke multiple threads of external code, but the only safe ways to do multiple matlab code threads are the ways in the parallel computing toolbox, or starting a second matlab process.
There are possibilities such as saving to .fig on the worker and opening the fig on the client. There are also possibilities involving having the worker send data back and having the client plot it.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Asynchronous Parallel Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by