How to convert .m file to .exe file?

5 views (last 30 days)
I converted .m file to .exe file using deploytool. When i run .exe file it opens with logo and just after that it close. Its not through any error or warning message. I am not able to figure out why its happening!! .m file contains classdef, in which using uicontrol i am creating GUI. Is it because i don't have any .fig file ? Thanks!
Nipurn Gulgulia
Nipurn Gulgulia on 12 Apr 2018
I tried with below simple function also, i am getting same thing. It show splash screen and than close!
function Test_1(varargin)
GUIsize = [520 420 520 420];
parent = figure('Name','Work Load','NumberTitle','off',...
set(parent, 'Units', 'pixels', 'Position', GUIsize);
ProjectPanel = uipanel(parent, 'Title', 'Projects',...
'Position', [0, .01, .505,.91]);
TimePanel = uipanel(parent, 'Title', 'Time Spent',...
'Position',[.5, .01, .495,.91]);
Top = uipanel(parent, 'Position', [0, .905, .997,.0875]);
Add = uicontrol(parent, 'Units', 'norm',...
'Position', [0.24, 0.917, 0.11, 0.067], 'String', 'Add','FontSize', 9);
Save = uicontrol(parent, 'Units', 'norm',...
'Position', [0.37, 0.917, 0.11, 0.067],'String', 'Save','FontSize', 9);

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 12 Apr 2018
Does your GUI use uiwait or waitfor to pause execution until the GUI is closed? If it does not, I believe what's happening is that the executable is opening your GUI and as soon as the GUI's program file finishes executing it exits, closing all figures as part of its shutdown process. [If it didn't, it would leak memory and graphics handles.] Adding uiwait or waitfor will prevent the GUI's program file from finishing until you close the GUI figure, and that would keep the executable running while you interact with your GUI.
If your GUI does use uiwait or waitfor, try launching the executable by typing its name at your operating system's command prompt rather than double-clicking on its icon. If it experiences an error on startup, that should display the message at the prompt. That may suggest a solution to you, or you can copy it into a comment on this question and that may suggest a solution to some of the people reading this discussion.
Steven Lord
Steven Lord on 12 Apr 2018
I tried building the application in release R2018a using the code you posted and was able to get a running application that left the figure on screen until I closed it myself. If you're not seeing the same results, you may want to contact Technical Support and work with them to determine why your results are different from mine. Use the Contact Us link in the upper-right corner of this page to contact Support.

Sign in to comment.

More Answers (1)

Veera Kanmani
Veera Kanmani on 12 Apr 2018
  1 Comment
Nipurn Gulgulia
Nipurn Gulgulia on 12 Apr 2018
I already converted, but its not working!

Sign in to comment.


Find more on Migrate GUIDE Apps in Help Center and File Exchange


No tags entered yet.

Community Treasure Hunt

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

Start Hunting!