MATLAB: My gui will not open when I click run (but it did before)

figguiwon't open

I used to be able to get my calculator program to run, and it would open and run perfectly fine until just recently. Now when I type run calc_project.m into the command line or press the start button in guide, there is nothing (sometimes a brief pause but no program). I believe this happened around the time when I started looking to see if I could make something dissapear, ironically, but I removed all of that code.

function varargout = calc_project(varargin)
% CALC_PROJECT MATLAB code for calc_project.fig
% CALC_PROJECT, by itself, creates a new CALC_PROJECT or raises the existing
% singleton*.
%

% H = CALC_PROJECT returns the handle to a new CALC_PROJECT or the handle to
% the existing singleton*.
%
% CALC_PROJECT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CALC_PROJECT.M with the given input arguments.
%
% CALC_PROJECT('Property','Value',...) creates a new CALC_PROJECT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before calc_project_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to calc_project_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help calc_project
% Last Modified by GUIDE v2.5 25-Mar-2019 15:03:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @calc_project_OpeningFcn, ...
'gui_OutputFcn', @calc_project_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before calc_project is made visible.
function calc_project_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to calc_project (see VARARGIN)
% Choose default command line output for calc_project
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes calc_project wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = calc_project_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in num0.
function num0_Callback(hObject, eventdata, handles)
% hObject handle to num0 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'0');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num1.
function num1_Callback(hObject, eventdata, handles)
% hObject handle to num1 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'1');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num2.
function num2_Callback(hObject, eventdata, handles)
% hObject handle to num2 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'2');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num3.
function num3_Callback(hObject, eventdata, handles)
% hObject handle to num3 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'3');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num4.
function num4_Callback(hObject, eventdata, handles)
% hObject handle to num4 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'4');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num5.
function num5_Callback(hObject, eventdata, handles)
% hObject handle to num5 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'5');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num6.
function num6_Callback(hObject, eventdata, handles)
% hObject handle to num6 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'6');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num7.
function num7_Callback(hObject, eventdata, handles)
% hObject handle to num7 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'7');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num8.
function num8_Callback(hObject, eventdata, handles)
% hObject handle to num8 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'8');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in num9.
function num9_Callback(hObject, eventdata, handles)
% hObject handle to num9 (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'9');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in buttonPoint.
function buttonPoint_Callback(hObject, eventdata, handles)
% hObject handle to buttonPoint (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string myString;
myString = get(handles.textScreen, 'String');
myNewString = strcat(myString ,'.');
myString = myNewString;
set(handles.textScreen,'String',myString);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in buttonEXP.
function buttonEXP_Callback(hObject, eventdata, handles)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
var string1;
var string2;
var operator;
string1 = get(handles.textScreen, 'String');
set(handles.savedNumber, 'String', string1);
%This is similar to exponent but it is not so it is 7
operator = '7';
set(handles.operatorText, 'String', operator);
set(handles.textScreen,'String','');
end
% hObject handle to buttonEXP (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in buttonClear.
function buttonClear_Callback(hObject, eventdata, handles)
% hObject handle to buttonClear (see GCBO)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
string clear;
clear = '';
set(handles.textScreen,'String',clear);
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in buttonAllClear.
function buttonAllClear_Callback(hObject, eventdata, handles)
var on;
on = get(handles.isItOn, 'String');
if strcmpi(on,'yes')
var clr;
clr = '';
set(handles.textScreen,'String',clr);
set(handles.savedNumber,'String',clr);
set(handles.operatorText, 'String',clr);
end
% hObject handle to buttonAllClear (see GCBO)

Best Answer

Your GUI is initializing with the "Visible' parameter set to 'off'. To fix this,
  1. Open your gui in GUIDE. guide('calc_project')
  2. Right click the grided background of the GUI and select 'Property Inspector'. The name of the window should indicate 'matlab.ui.Figure'.
  3. Scroll down to the 'Visible' property. Click next to "Off" and it should change to "On" then activate the on-checkbox.
  4. Close the properties window, then save the gui: file > save
  5. now run the gui and it should appear.
Related Question