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

조회 수: 1 (최근 30일)
Jason Brogan
Jason Brogan 2022년 1월 7일
댓글: Walter Roberson 2022년 1월 7일
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
Walter Roberson
Walter Roberson 2022년 1월 7일
Your code does not appear to be taking any care about directories such as ctfroot()?

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

답변 (1개)

Steven Lord
Steven Lord 2022년 1월 7일
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.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by