load .mat file fails in Web App
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
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 Kommentare
  Muhammed Yaseen
    
 am 16 Aug. 2021
				
      Bearbeitet: Muhammed Yaseen
    
 am 16 Aug. 2021
  
			I understand that you are unable to load a file which you have created in the Web app, but you are able to load it in MATLAB. Can you see if the following links can help?
Antworten (0)
Siehe auch
Kategorien
				Mehr zu MATLAB Web App Server finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

