If matlab -desktop elseif matlab -nodesktop
조회 수: 5 (최근 30일)
이전 댓글 표시
How i can check if my scripts/functions running with gui matlab or not? something like this:
if "matlab -desktop"
%
else
%
end
댓글 수: 0
채택된 답변
Jan
2018년 6월 23일
See: https://www.mathworks.com/matlabcentral/answers/101542-is-it-possible-to-programmatically-check-whether-matlab-has-been-started-with-the-nodisplay-optio. But this might do the trick also:
usejava('desktop')
or
java.lang.System.getProperty( 'java.awt.headless' )
댓글 수: 3
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
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!