Using Matlab compiler which(filename) can not locate file

11 次查看(过去 30 天)
Hi,
I'm compiling into an executable a matlab function that includes a which() finction:
str = which(filename)
The file is on the path and the function returns the file location successfully if I run from matlab but does not work if I compile the app into an executable.
This works in 2018B but stopped working in 2020A.
This seems to be a bug in 2020A. Any suggestions for a workaround?
Thanks!

回答(2 个)

Chidvi Modala
Chidvi Modala 2020-6-12
I tried generating executable for the following piece of code in MATLAB R2020A
function code()
filename = 'abc.m';
str = which(filename);
disp(str)
end
It worked fine. Can you elaborate on what error you were getting and code you were trying to run?

Steven Lord
Steven Lord 2020-6-12
What are you planning on doing with that information?
If you're planning to use this to try to run a function the user provides when running the executable, this will not work.
If you're using this to try to locate a data file, you should read this documentation page.
Also, what does "stopped working" mean in this context?
  • Do you receive warning and/or error messages?
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Does your application crash? If so please send the crash log file (with a description of what you were running or doing in the executable when the crash occured) to Technical Support using the telephone icon in the upper-right corner of this page so we can investigate.
  1 个评论
Nevine
Nevine 2020-6-18
Thanks for the reply and we have resolved the issue. The file is being used as a marker file to determine the path to assembly dlls needed for our application. The which() function is being called from within the Matlab App Designer. The code is then compiled to an executable using the Matlab compiler. The issue is that the which command was returning an empty string as it was failing to locate the file. It seems that the file was not included in the compiler project file as part of the auto generation from the code analysis. Once we included it manually, it is able find the path. Thanks again!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by