Hi folks,
I have an App running on Web App Server. What I'm trying to do is read in a .mat-file and set some values depending on the file.
My aim is to get to a point where a user can make some changes on the GUI/app then save the entered values to a custom .mat-file and load them back into the app to a later point in time. I hope my problem is okay to understand.
If I run my App out of Matlab save/load works fine. But on the deployed app on the server it doesn't.
I get the following messages in the log of the server:
% saveload.mat is uploaded successfully
% Error using load
% Unable to read file 'saveload.mat'. No such file or directory.
What am I doing wrong?

5 件のコメント

Mario Malic
Mario Malic 2020 年 10 月 30 日
saveload.mat probably is not on the search path of Web App Server. Find the folder where uploaded files are saved to.
Dominik Müller
Dominik Müller 2020 年 10 月 30 日
編集済み: Dominik Müller 2020 年 10 月 30 日
Okay there is a path on the server where the document get's saved. But the path seems to be depending on the current session. So everytime I connect to the server and try to load a document the Windows path is a different one.
Is there a way to define a path where the upload should go to?
Mario Malic
Mario Malic 2020 年 10 月 30 日
Are you able go identify the session name/instance? If yes, you can use genpath and/or addpath, otherwise you can add all folders within the session folder to the search path, but this wouldn't be a good solution.
Dominik Müller
Dominik Müller 2020 年 10 月 30 日
Thank you Mario, you led me to the right direction. Problem's solved now.
Mario Malic
Mario Malic 2020 年 10 月 30 日
編集済み: Mario Malic 2020 年 10 月 30 日
Great! Also, don't use cd, rather supply full or relative path to load function. It is slow and can cause issues.

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

 採用された回答

Dominik Müller
Dominik Müller 2020 年 10 月 30 日

0 投票

The solution is quite simple:
[file,path] = uigetfile('*.mat'); % see matlab documentation of uigetfile
cd(path)
data = load(file);

1 件のコメント

Yiling
Yiling 2024 年 7 月 25 日
Hi, what if I don't want to have the dialog box open? I've already uploaded the .mat file as the supporting file when packaging the APP. Is this a way that I can directly code into the app so the web server automatically detects the .mat file on the web server path and load it?
Put it anothe way, when uploading the .mat file as the supporting file, what is the web server path where the .mat file gets stored?

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Web App Server についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by