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

 Accepted Answer

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

3 Comments

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?
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

Sign in to comment.

More Answers (0)

Categories

Asked:

on 23 Jun 2018

Commented:

Jan
on 29 Jul 2020

Community Treasure Hunt

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

Start Hunting!