Why is my web app unable to locate a file included during compilation?
조회 수: 1 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2025년 11월 4일 0:00
답변: MathWorks Support Team
2025년 11월 4일 21:10
I have a MATLAB app that depends on a data file, "test_data.xlsx". When the app is run from App Designer, this file is successfully found at runtime and the app runs without issue. However, when I compile this as a web app (with the data file included during compilation) and run it on MATLAB Web App Server, I get an error that the file can't be found.
Why is my code not able to locate this file dependency, even when the file is included in the packaged CTF?
채택된 답변
MathWorks Support Team
2025년 11월 4일 0:00
This may be due to the path used to access the file in your code.
In deployed environments, the simplest way to obtain the full path to a file is using the which function:
if isdeployed
file_path = which('test_data.xlsx');
end
Alternatively, you can construct the full file path using ctfroot:
if isdeployed
file_path = fullfile(ctfroot,'folderA','test_data.xlsx');
end
For more information on both these options, see Include and Access Files in Packaged Applications.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Web App Server에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!