MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   确定MATLAB是从OS GUI启动还是作为并行工具箱线程启动 (https://www.labfans.com/bbs/showthread.php?t=26735)

poster 2019-12-14 20:46

确定MATLAB是从OS GUI启动还是作为并行工具箱线程启动
 
与[URL="https://stackoverflow.com/questions/2020790/r-script-determine-whether-the-script-is-run-in-the-gui-or-from-command-line"]关于R的问题[/URL]类似,有没有办法确定给定的MATLAB实例是由用户启动的还是由并行工具箱调度程序生成的?



[B]回答:[/B]

[I]警告:未经测试的代码[/I]

这似乎可以解决问题:

if isempty(getCurrentWorker) % Do things if launched as a worker else % Do things if launched in a GUI session end 这是参考: [URL="http://www.mathworks.com/help/toolbox/distcomp/getcurrentworker.html"]http[/URL] : [URL="http://www.mathworks.com/help/toolbox/distcomp/getcurrentworker.html"]//www.mathworks.com/help/toolbox/distcomp/getcurrentworker.html[/URL]



[url=https://stackoverflow.com/questions/5462518]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:19

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.