Borrar filtros
Borrar filtros

Plot a figure inside parfeval

17 visualizaciones (últimos 30 días)
or ohev shalom
or ohev shalom el 31 de Jul. de 2019
Comentada: Walter Roberson el 31 de Jul. de 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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Jul. de 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 comentarios
or ohev shalom
or ohev shalom el 31 de Jul. de 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 el 31 de Jul. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Asynchronous Parallel Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by