If matlab -desktop elseif matlab -nodesktop

How i can check if my scripts/functions running with gui matlab or not? something like this:
if "matlab -desktop"
%
else
%
end

 採用された回答

Jan
Jan 2018 年 6 月 23 日

1 投票

usejava('desktop')
or
java.lang.System.getProperty( 'java.awt.headless' )

3 件のコメント

Andrea Stevanato
Andrea Stevanato 2018 年 6 月 23 日
Thanks!
Edward
Edward 2020 年 7 月 27 日
I don't understand from this answer what is the correct conditional to use to check whether or not Matlab was launched without the desktop. Can you please elaborate?
Jan
Jan 2020 年 7 月 29 日
if usejava('desktop')
disp('This Matlab instance runs with a desktop')
else
% No message here due to the missing comamnd window.
end
Alternatively:
if java.lang.System.getProperty('java.awt.headless')
% No command window...
else
disp('This Matlab instance runs with a desktop')
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2018 年 6 月 23 日

コメント済み:

Jan
2020 年 7 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by