Is there a simple way to spawn a copy of your current MATLAB workspace into a new process/thread?

3 visualizzazioni (ultimi 30 giorni)
If not, is there an unnecessarily complex way to do it? ;)
I've written some code that creates plots from EEG time series data (stored in the workspace). The user navigates between the plots using the keyboard, and this lets them see/compare features between the plots.
The only problem is that it blocks the main thread. Running it in a separate thread would be ideal, but it seems like 'batch' doesn't show plots - and it's slow!
system('matlab') works in creating a new process, but the workspace is empty. It's also quite slow.
Is there a simple way to initialise a new process/thread, with my current workspace, so that I can run the plotting script without blocking execution?
Thanks, ~Chris

Risposta accettata

Jan
Jan il 10 Apr 2017
Modificato: Jan il 10 Apr 2017
What does block the main thread? If you have a bunch of GUIs, the callbacks are processed on demand only. As long as there are no waitfor commands or modal dialogs, nothing is blocked.
A save() command saves all variables in the current workspace to the disk. With load() they can be reloaded in another thread. But I assume, that this indirection is a bad idea. Better create a non-blocking interface.

Più risposte (1)

Chris Esposito
Chris Esposito il 18 Apr 2017
Thanks, Jan. I ended up creating a save() and load() sequence together with arguments fed to the system('matlab') call to hack it together, but you are right - a separate GUI would be the better option.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by