Problem compiling a GUI
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
I'm trying creat a a Windows standalone application of a simple GUI with the deploytool. I got generate the executable, but when I try open it I receive the following message in the prompt window:
"??? Undefined function or variable 'file_name'. MATLAB : UndefinedFunction"
I'm using the MATLAB 2008a (7.6.0). What's the problem?
0 件のコメント
回答 (4 件)
Fangjun Jiang
2011 年 11 月 27 日
What do you mean by "when I try open it"? If you've got an executable (*.exe file), you should run it in Windows Command Window, not in MATLAB Command Window.
5 件のコメント
Image Analyst
2011 年 11 月 27 日
No, mfilename is. Please post the entire contents of your startup code, at least until you see the first reference to file_name. If you used GUIDE, this would be the OpenFcn() function.
Image Analyst
2011 年 11 月 27 日
You never assigned a value to file_name by the time it executed that line of code. Try making your code more robust by using constructs like try/catch, isempty(), exist(), and so on. When you're making an executable for other users to run, that is no time to get loose and sloppy with your code. In my executables, every single function has try/catch and I always construct full filenames with fullfile(), check for existence, create folders if necessary, validating values, validating user inputs, etc. A substantial number of lines in my code, maybe 10%-30%, is spent idiotproofing the code for unexpected things. Sounds like you have little or none of that. It saves you time to cut out all the bulletproofing but will get you in the end because the unexpected will always happen sooner or later.
try
fullFileName = fullfile(pwd, 'myFile.dat');
% Make sure the file exists.
if ~exist(fullFileName)
errorMessage = sprintf('Error in function blah_blah_blah\nFile does not exist:\n%s', fullFileName);
% Show in console window.
fprintf('%s\n', errorMessage);
% Pop up dialog box also
uiwait(warndlg(errorMessage));
return;
end
% File was found - continue with your other code.
catch ME
% Gets here for a general exception.
errorMessage = sprintf('Error in function blah_blah_blah.\n\nError Message:\n%s', ME.message);
% Show in console window.
fprintf('%s\n', errorMessage);
% Pop up dialog box also
uiwait(warndlg(errorMessage));
end
0 件のコメント
Peter Ferreira
2011 年 12 月 20 日
3 件のコメント
Fangjun Jiang
2011 年 12 月 20 日
It might be this one.
http://www.mathworks.com/support/bugreports/436507
Image Analyst
2011 年 12 月 20 日
Peter, what was the name of the folder you installed your "file_name.exe" app to? Was it really long? When you run your exe, that's not actually running the exe and it unpacks a ton of stuff (including the *real* actual executable) into the folder defined by MCR_CACHE_ROOT. I usually set mine to . (dot) so that it unpacks all that stuff into subfolders of my app's folder instead of some weird hidden folder deep within c:\documents and settings\username\local setting\blah\blah\blah. You can put the line "ctfroot" in your startup code to have it print the folder in the command window when it starts (if it starts).
Wilson
2013 年 3 月 20 日
編集済み: Wilson
2013 年 3 月 20 日
Hi everyone
I received this error when i tried to executed Multitest_1.exe
Multitest_1_OpeningFcn (line 67)
daq.createSession requires a vendor ID. Use 'daq.getVendors()' for a list of
vendors.
I the Multitest_1.m i did
id = get(daq.getVendors(),'ID') obj = daq.createSession(id)
And in the matlab, the program run very well.
Any idea what is the problem with the compiler?
matlab version R2012b
thanks
wilson
1 件のコメント
Image Analyst
2013 年 3 月 20 日
Please start your own discussion for this rather than posting your question as an "Answer" to a 16 month old question from someone else.
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!