Distinguish installed MATLAB from Online/Mobile versions

23 views (last 30 days)
MATLAB has commands such as ispc/ismac/isunix and computer to determine the local computing environment. Is there a way to distinguish MATLAB Online and MATLAB Mobile from a local install? Both the online and mobile versions report themselves as 64-bit Linux, which is presumably the Mathworks server running behind the scenes. Both also have an enviroment variable MW_DDUX_APP_NAME that does not appear on Mac or Windows installs, with the very telling value MATLAB_ONLINE. My assumption is that a local Linux install would not have that variable, and if a local server did, the value would be different (unless one was running MATLAB Online behind a firewall).
So far I haven't found a simple way of separating online and mobile versions, apart from a try/catch block containing a command that does not work on the latter (such as uifigure). That's not very robust--is there a better way?
  4 Comments
Steven Lord
Steven Lord on 24 Sep 2025 at 17:11
I have a graphical user interface that works well on local installs (at least Mac and Windows, Linux not yet tested), partially works in MATLAB Online, and cannot work on MATLAB Mobile.
What limits the ability of that UI to work in MATLAB Online and what prevents it from working on MATLAB Mobile? In the past I would have suggested using the usejava function to detect if certain types of UI capability were present, but I'm not sure that would solve the problem in the scenario you described. But if it's something else (an inability to call system to make changes to the OS configuration, for example) that might be checkable via a different mechanism.
Dan Dolan
Dan Dolan on 24 Sep 2025 at 17:52
The problem with MATLAB Mobile is easy to describe: no uifigures, uilabels, uibuttons, and so forth. Legacy uicontrols can be requested but are not actually active. I'm told that AppDesigner apps should work, but I have not tested them myself. I also abhor the App Designer-- it's better than GUIDE, but that was not a particular high bar to clear.
The MATLAB Online issue is more subtle, and I am still working through it. My specific task combines components from three invisible uifigures into separate tabs on the left side of a new uifigure. The right side is filled by a uipanel that resizes with the uifigure. Plots will go on the right side and scale with the figure, while controls on the left side remains fixed. This works fine on Mac and Windows, but the new figure is not displayed on MATLAB Online. I can trick the system by forcing the figure to be docked (although this messes with component locations) and then undocking it.
I suspect the issue is tied to the use of normalized units when I create the right panel. The screen resolution reported by MATLAB Online has no relationship to my actual display, so it might be creating this massive figure that cannot actually be shown. The web interface handles figures a little differently too--they are either docked, actively displayed, or locally minimized. Traditiional platforms can show the command window and figures simultaneously, and that is how I am accustomed to designing interfaces.

Sign in to comment.

Accepted Answer

Dan Dolan
Dan Dolan on 1 Oct 2025 at 20:45
Here is the best I have so far.
% environment Determine computing environment
%
% This function determines the computing environment.
% value=environment();
% The output "environment" can be 'Windows', 'Mac', 'Linux', 'Online', or
% 'Mobile'. Calls without an output request:
% environment();
% print information in the command window.
%
% Unlike MATLAB's builtin commands, such as computer, this function
% distinguishes MATLAB Online and MATLAB Mobile from standard Linux
% environments.
%
% See also computer, isunix, ismac, ispc
%
function varargout=environment()
local=true();
if ispc()
value='Windows';
elseif ismac()
value='Mac';
else
value='Linux';
list=getenv();
pattern='MATLAB_ONLINE';
match=false();
name=keys(list);
for n=1:numel(name)
if strcmpi(name{n},pattern) || strcmpi(list(name{n}),pattern)
match=true();
break
end
end
if match
local=false();
value='Online';
try
fig=uifigure('Visible','off');
delete(fig);
catch
value='Mobile';
end
end
end
% manage output
if nargout() > 0
varargout{1}=value;
elseif local
fprintf('Environment is %s\n',value);
else
fprintf('Environment is MATLAB %s\n',value);
end
end

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!