Why is opening a file in compiled mode different than direct Matlab mode?

1 vue (au cours des 30 derniers jours)
Jason Brogan
Jason Brogan le 7 Jan 2022
I have a simple function that opens a settings file and displays its contents.
When running from Matlab, everything is fine. When running the compiled version, the contents of the file are very different.
It seems I need to specify the full path of the file. I did not need to with previous versions of Matlab.
function evalTest()
settingsFile = 'evalTestSettings.m';
[paramfid, msg] = fopen(settingsFile,'rt');
if paramfid == -1
error('Cannot open %s; %s', settingsFile, msg);
end
sParamFile = fscanf(paramfid,'%c');
fclose(paramfid);
msgbox(sParamFile);
end
  3 commentaires
Jason Brogan
Jason Brogan le 7 Jan 2022
Here are screenshots of the differences.
Walter Roberson
Walter Roberson le 7 Jan 2022
Your code does not appear to be taking any care about directories such as ctfroot()?

Connectez-vous pour commenter.

Réponses (1)

Steven Lord
Steven Lord le 7 Jan 2022
If you're trying to have your compiled application run code that was not present and included in the application at the time the application was created, either by directly calling a separate function file or reading in the body of a function file (or a text file containing MATLAB commands) and calling eval or something similar, this will not work. [The name of your function suggests to me that this is your ultimate goal.]
"MATLAB Runtime only works on MATLAB code that was encrypted when the deployable archive was built. Any function or process that dynamically generates new MATLAB code will not work against MATLAB Runtime." and "If you require the ability to create MATLAB code for dynamic run-time processing, your end users must have an installed copy of MATLAB." as stated on this documentation page.

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by