MATLAB Answers

Matlab Production Server Error Using Load Command

조회 수: 4(최근 30일)
Marc McLean
Marc McLean 22 Jun 2020
답변: Fleur Fok 26 Aug 2020
When using the load command in a script compiled to a CTF file running on Matlab Production Server, for example:
dataset_load = load('results/dataset_scaled_fixedBins.mat');
I get the following error:
Error: Unable to read file 'results/dataset_scaled_fixedBins.mat'. No such file or directory.
I put the .mat file in the auto_deploy folder, but it is not found. I then put the script in the script's .m file path
C:\\Program Files\\MATLAB\\MATLAB Production Server\\R2019b\\script\\mps1\\.mps_deployed\\phase22_generate_histogram2_27\\phase22_gene\\phase22_generate_histogram2.m
but that does not work either.
Where does a script look when using the load command from a CFT file?

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Fleur Fok
Fleur Fok 26 Aug 2020
I ran into the same issue while trying to load a file in a deployed application. Because you know the structure of the folders you deploy, you can make use of Matlab's mfilename function. The following worked for me:
path = mfilename('fullpath'); % retrieve full path of current script
path = strrep(path,'\[folder]\[current_function]',''); % remove part of the path
path = fullfile(path, 'results\dataset_scaled_fixedBins.mat'); % add new end to the path
Where [folder]\[current_function] represent the folder structure of where this code resides, while 'results\dataset_scaled_fixedBins.mat' is the structure that is added to complete the path.
I hope this helps!

  댓글 수: 0

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Kojiro Saito
Kojiro Saito 26 Jun 2020
You can check by the work folder of the CTF file by using pwd in MATLAB Production Server. I suppose now the work folder is C:\Program Files\MATLAB\MATLAB Production Server\R2019b\script\mps1.
So, if you put dataset_scaled_fixedBins.mat file in C:\Program Files\MATLAB\MATLAB Production Server\R2019b\script\mps1\results, it would work.
But C:\Program Files\MATLAB\MATLAB Production Server\R2019b is installation folder and it's not a good way to put input data or CTF files in this folder.
I recommend to set up an instance in other folders than C:\Progam Files.
For example,
mps-new C:\Work\mps1

  댓글 수: 0

댓글을 달려면 로그인하십시오.




Community Treasure Hunt

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

Start Hunting!

Translated by