Change the main BasicScreen function back to how it was (in particular, it appears you inadvertently removed the text "(varargin)" from the function definition; in general, you should never edit the main function of a GUIDE m-file):
function varargout = BasicScreen(varargin)
% BASICSCREEN MATLAB code for BasicScreen.fig
% BASICSCREEN, by itself, creates a new BASICSCREEN or raises the existing
% singleton*.
%
% H = BASICSCREEN returns the handle to a new BASICSCREEN or the handle to
% the existing singleton*.
%
% BASICSCREEN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BASICSCREEN.M with the given input arguments.
%
% BASICSCREEN('Property','Value',...) creates a new BASICSCREEN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before BasicScreen_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to BasicScreen_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 BasicScreen
% Last Modified by GUIDE v2.5 23-Apr-2024 11:15:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @BasicScreen_OpeningFcn, ...
'gui_OutputFcn', @BasicScreen_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin > 1 && 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
And put all your global declarations and other initialization code in BasicScreen_OpeningFcn.
% --- Executes just before BasicScreen is made visible.
function BasicScreen_OpeningFcn(hObject, eventdata, handles, varargin)
global x0 y0
global ProbR ProbY ExR ExY
disp("in opening")
ProbR=0.6;
ProbY=0.4;
ExR=1;
ExY=1;
x0
y0
probR
probY
% Create the RedBox and YellowBox rectangles
% handles.RedBox = rectangle('Position', [x0, y0, probR, 50]);
% handles.YellowBox = rectangle('Position', [x0 + probR, y0, probY, 50]);
% Set the axis limits
% axis([0 100 0 100]);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes BasicScreen wait for user response (see UIRESUME)
% uiwait(handles.figure1);