How can I determine if a matlab app is running as a web app?

12 ビュー (過去 30 日間)
Roger Schvaneveldt
Roger Schvaneveldt 2020 年 11 月 2 日
編集済み: Walter Roberson 2024 年 1 月 31 日
I need to retrieve and save data differently when an app is running as a web app so I need something like is deployed that distinguishes between web deployment and standalone app deployment.
  2 件のコメント
Roger Schvaneveldt
Roger Schvaneveldt 2020 年 11 月 5 日
編集済み: Roger Schvaneveldt 2020 年 11 月 5 日
I found a suggestion that led me to solve the problem with this function which requires creating an empty file named, file.to.add.to.web.app, and adding that file to the compiled web app.
function tf = iswebdeployed()
% tf = iswebdeployed()
% tests whether an app is running as a web app
% must include a file named file.to.add.to.web.app when compiling a web app
% tf = isdeployed && exist('file.to.add.to.web.app', "file");
tf = isdeployed && exist('file.to.add.to.web.app', "file");
end
William Thielicke
William Thielicke 2024 年 1 月 21 日
I would need something similar, my code would need something like "ismatlabonline" in addition to ispc, isunix and ismac... Nothing like this available?

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

回答 (1 件)

Hiro Yoshino
Hiro Yoshino 2020 年 11 月 2 日
Web apps run in your browser and stand-alone app opens your system window(s) and run in it (them).
  6 件のコメント
Mike McCullough
Mike McCullough 2024 年 1 月 31 日
As a developer and seller of software, all files the user needs should NEVER be in the same folder. They need to be on a server or in the ROOT of C:. So my readmatrix(), open(), & load() have their files in a ROOT folder or:
weight = load('c:\appsM\54WEIGHT.DAT'); % C drive
weight = load('/MATLAB Drive/appsM/54WEIGHT.DAT'); matlab drive
MatLab engineers have no idea how to implement a MatLab program, sad real sad!!!!
Boo Linux.
Walter Roberson
Walter Roberson 2024 年 1 月 31 日
編集済み: Walter Roberson 2024 年 1 月 31 日
if ispc
filebase = 'C:';
else
filebase = '/MATLAB Drive';
end
filename = fullfile(filebase, 'appsM', '54WEIGHT.DAT');
weight = load(filename);
Hardcoding the base directory is a bad idea even on Windows, as doing so restricts you to a particular directory structure. You should be writing your code so that moving your files around requires only a small amount of changes to initialization.
Suppose that MATLAB Online were to switch to Windows. Then it isn't going to happen to have the same directory structure that you have.

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

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by