load .mat file fails in Web App

4 次查看(过去 30 天)
Hello,
i am trying to implement save/load functionality for a web app, everything works fine locally but load(filename) function fails on a web app,
%% Save Function
[file,path] = uiputfile('*.mat','Save patient data as .mat file')
if file~=0
resultFilePath = fullfile(path,file)
inputs={};
for i=1:numel(app.UIList)
inputs{i}=app.UIList{i}{2}.Data; % app.UIList{i}{2} are UITables
end
save(resultFilePath,'inputs','-v7','-nocompression')
end
%% Load Function
[file,pathn] = uigetfile('*.mat','File Selector');
disp(file)
disp(pathn)
if isequal(file,0)==false
inpuFilePath = fullfile(pathn,file)
try
Data=load(inpuFilePath);
inputs=Data.inputs;
%
%... CODE BLOCK FOR PROCESSING 'inputs'
%
catch ME
fprintf('error: \n');
fprintf('%s : %s\n',ME.identifier,ME.message);
fprintf('........\n');
fid=fopen(inpuFilePath);
dat=fread(fid,[1,90],'uint8');
fprintf('%s ',dat)
fprintf('\n')
end
end
Saving works fine, i get a file that i can load in matlab and everything is there, so the file is not corrupted, however when i load in web app, it says it is corrupted, why???
2021-08-13 10:51:47 test2.mat is uploaded successfully
2021-08-13 10:51:47 test2.mat
2021-08-13 10:51:47 /local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/
2021-08-13 10:51:48 inpuFilePath =
2021-08-13 10:51:48 '/local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/test2.mat'
2021-08-13 10:51:48 error:
2021-08-13 10:51:48 MATLAB:load:unableToReadMatFile : Unable to read MAT-file /local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/test2.mat. File might be corrupt.
2021-08-13 10:51:48 ........
2021-08-13 10:51:48 MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Fri Aug 13 10:49:37 2021
  2 个评论
Deividas Eringis
Deividas Eringis 2021-8-16
i have seen the second link, that's why i did fread() to see if the file is there at all,
the first link is interesting it might be that there is an older runtime installed, i will contact my server administrator and check, thanks, i know for a fact that the oldest runtime installed could be 2019b which i would not expect to have problems loading .mat files.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Web App Server 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by