Parse Error in Matlab: Unexpected Matlab Operator - matlab

I'm getting this unwanted parse error saying
Error: File: GUI.m Line: 284 Column: 5. Unexpected MATLAB operator.
However, I cannot see any unexpected operator. Can anybody diagnose this issue?
Here's my code:
function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_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 GUI
% Last Modified by GUIDE v2.5 24-May-2017 23:28:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #GUI_OpeningFcn, ...
'gui_OutputFcn', #GUI_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
% End initialization code - DO NOT EDIT
% --- Executes just before GUI is made visible.
function GUI_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 GUI (see VARARGIN)
% Choose default command line output for GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_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 START.
function START_Callback(hObject, eventdata, handles)
% hObject handle to START (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Cfilename;
global Cpathname;
global Tfilename;
global Tpathname;
fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');
tline = fgetl(fid);
C = strsplit(tline,{',',' ','[',']'});
set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'
Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)
Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tfilename = C{1,2};
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)
X = strsplit(C{1,1},{'-','.'});
global I;
global J;
I = X{1};
J = X{2};
function fname_Callback(hObject, eventdata, handles)
% hObject handle to fname (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of fname as text
% str2double(get(hObject,'String')) returns contents of fname as a double
% --- Executes during object creation, after setting all properties.
function fname_CreateFcn(hObject, eventdata, handles)
% hObject handle to fname (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function shaColor_Callback(hObject, eventdata, handles)
% hObject handle to shaColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of shaColor as text
% str2double(get(hObject,'String')) returns contents of shaColor as a double
% --- Executes during object creation, after setting all properties.
function shaColor_CreateFcn(hObject, eventdata, handles)
% hObject handle to shaColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function char_Callback(hObject, eventdata, handles)
% hObject handle to char (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of char as text
% str2double(get(hObject,'String')) returns contents of char as a double
% --- Executes during object creation, after setting all properties.
function char_CreateFcn(hObject, eventdata, handles)
% hObject handle to char (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function charCol_Callback(hObject, eventdata, handles)
% hObject handle to charCol (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of charCol as text
% str2double(get(hObject,'String')) returns contents of charCol as a double
% --- Executes during object creation, after setting all properties.
function charCol_CreateFcn(hObject, eventdata, handles)
% hObject handle to charCol (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function GLat_Callback(hObject, eventdata, handles)
% hObject handle to GLat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of GLat as text
% str2double(get(hObject,'String')) returns contents of GLat as a double
% --- Executes during object creation, after setting all properties.
function GLat_CreateFcn(hObject, eventdata, handles)
% hObject handle to GLat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function GLong_Callback(hObject, eventdata, handles)
% hObject handle to GLong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of GLong as text
% str2double(get(hObject,'String')) returns contents of GLong as a double
% --- Executes during object creation, after setting all properties.
function GLong_CreateFcn(hObject, eventdata, handles)
% hObject handle to GLong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
end
set(hObject,'BackgroundColor','white');
function shape_CreateFcn(hObject, eventdata, handles)
% hObject handle to shape (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Orient_Callback(hObject, eventdata, handles)
% hObject handle to Orient (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Orient as text
% str2double(get(hObject,'String')) returns contents of Orient as a double
function Orient_CreateFcn(hObject, eventdata, handles)
% hObject handle to Orient (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (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 CANCEL.
function CANCEL_Callback(hObject, eventdata, handles)
% hObject handle to CANCEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function gLat2_Callback(hObject, eventdata, handles)
% hObject handle to gLat2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of gLat2 as text
% str2double(get(hObject,'String')) returns contents of gLat2 as a double
% --- Executes during object creation, after setting all properties.
function gLat2_CreateFcn(hObject, eventdata, handles)
% hObject handle to gLat2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function gAlt_Callback(hObject, eventdata, handles)
% hObject handle to gAlt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of gAlt as text
% str2double(get(hObject,'String')) returns contents of gAlt as a double
% --- Executes during object creation, after setting all properties.
function gAlt_CreateFcn(hObject, eventdata, handles)
% hObject handle to gAlt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit12 as text
% str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function GBear_Callback(hObject, eventdata, handles)
% hObject handle to GBear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of GBear as text
% str2double(get(hObject,'String')) returns contents of GBear as a double
% --- Executes during object creation, after setting all properties.
function GBear_CreateFcn(hObject, eventdata, handles)
% hObject handle to GBear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (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 NEXT.
function NEXT_Callback(hObject, eventdata, handles)
% hObject handle to NEXT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function shape_Callback(hObject, eventdata, handles)
% hObject handle to shape (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of shape as text
% str2double(get(hObject,'String')) returns contents of shape as a double
%fid = fopen('C:\Users\Vikcy\Desktop\Files\Values.txt');
%C = textscan(fid, '%s')
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in preTar.
function preTar_Callback(hObject, eventdata, handles)
% hObject handle to preTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;
J=int32(str2num(J));
J=J-1;
J=int2str(J);
Tfilename = strcat(I,'-',J,'.jpg');
fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');
for i = 1:count
tline = fgetl(fid);
end
C = strsplit(tline,{',',' ','[',']'});
set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'
Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)
Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)
axes(handles.axes1);
imshow(image)
% --- Executes on button press in nexTar.
function nexTar_Callback(hObject, eventdata, handles)
% hObject handle to nexTar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;
J=int32(str2num(J));
J=J+1
J=int2str(J);
Tfilename = strcat(I,'-',J,'.jpg');
fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');
for i = 1:count
tline = fgetl(fid);
end
C = strsplit(tline,{',',' ','[',']'});
set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'
Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)
Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)
axes(handles.axes1);
imshow(image)

From the Matlab documentation:
Functions end with either an end statement, the end of the file, or the definition line for a local function, whichever comes first. The end statement is required if:
Any function in the file contains a nested function (a function completely contained within its parent).
The function is a local function within a function file, and any local function in the file uses the end keyword.
The function is a local function within a script file.
You use the end keyword in your function Orient_CreateFcn, so all of your local functions require an end statement.
This is good coding practise anyway, as it makes your code more clear. For example it clarifies whether a local function is nested or not without having to find the parent function's end

You have an extra end on line 45, just delete it. See below
gui_mainfcn(gui_State, varargin{:});
end
end % <- this one

Related

Error ploting bode , nyquist and nichols responses in gui matlab

I want to create a graphical interface with the GUIDE Matlab that displays diffrent responses of a transfer function : step , impulse , bode , nyquist and nichols responses.
it works fine for the step and impulse responses but with nyquist , bode and nichols it dosen't work , i should add 'squeeze' to the 'plot' function but it's not exactly the correct response !
this is the error when i try with plot only :
??? Error using ==> plot Data may not have more than 2 dimensions
This is th LTI.fig file
The following code is the content of the .m file
function varargout = LTI(varargin)
% LTI M-file for LTI.fig
% LTI, by itself, creates a new LTI or raises the existing
% singleton*.
%
% H = LTI returns the handle to a new LTI or the handle to
% the existing singleton*.
%
% LTI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LTI.M with the given input arguments.
%
% LTI('Property','Value',...) creates a new LTI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before LTI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to LTI_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 LTI
% Last Modified by GUIDE v2.5 24-Nov-2014 10:41:38
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #LTI_OpeningFcn, ...
'gui_OutputFcn', #LTI_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 LTI is made visible.
function LTI_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 LTI (see VARARGIN)
% Choose default command line output for LTI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes LTI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = LTI_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;
function numerateur_Callback(hObject, eventdata, handles)
% hObject handle to numerateur (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of numerateur as text
% str2double(get(hObject,'String')) returns contents of numerateur as a double
% --- Executes during object creation, after setting all properties.
function numerateur_CreateFcn(hObject, eventdata, handles)
% hObject handle to numerateur (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function denumerateur_Callback(hObject, eventdata, handles)
% hObject handle to denumerateur (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of denumerateur as text
% str2double(get(hObject,'String')) returns contents of denumerateur as a double
% --- Executes during object creation, after setting all properties.
function denumerateur_CreateFcn(hObject, eventdata, handles)
% hObject handle to denumerateur (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in rep_indic.
function rep_indic_Callback(hObject, eventdata, handles)
% hObject handle to rep_indic (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
plot(step(G))
grid on
% --- Executes on button press in lieu_bode.
function lieu_bode_Callback(hObject, eventdata, handles)
% hObject handle to lieu_bode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
plot(squeeze(bode(G)))
grid on
% --- Executes on button press in rep_impuls.
function rep_impuls_Callback(hObject, eventdata, handles)
% hObject handle to rep_impuls (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
plot(impulse(G))
grid on
% --- Executes on button press in lieu_nyquist.
function lieu_nyquist_Callback(hObject, eventdata, handles)
% hObject handle to lieu_nyquist (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
plot(s(nyquist(G)))
grid on
% --- Executes on button press in lieu_nichols.
function lieu_nichols_Callback(hObject, eventdata, handles)
% hObject handle to lieu_nichols (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
plot(squeeze(nichols(G)))
grid on
You don't provide the *.fig file to go with your code, but I suspect I know what the problem is: bode, nyquist and nichols produce the plot automatically, you don't need to call the plot function. Check the documentation for the correct way to call these functions. In your GUI, replace:
plot(squeeze(bode(G))) by bode(G)
plot(s(nyquist(G))) [sic] by nyquist(G)
plot(squeeze(nichols(G))) by nichols(G)
EDIT based on comments
I think all you need to do is
num= str2num(get(handles.numerateur,'String'));
denum = str2num(get(handles.denumerateur,'String'));
G=tf([num],[denum]);
axes(handles.figure)
step(G)
grid on
and the same applies for bode, nyquist, nichols and impulse, i.e. just create a set of axes in the figure and the plot will be displayed in those axes by default.

Matlab gui - cannot set text box value on button push if directly run .fig file

I'm making a GUI for the Bisection method in matlab and when I push the button to calculate the root I'm displaying the result in a text box field called rezInput.
If I open the *.m file and run the gui from here - everything works.
The problem:
If I directly open the *.fig file, enter the values (function, interval, tolerance) and press the button I get an error 'rezInput field does not exist'.
Here's the error:
??? Reference to non-existent field 'rezInput'.
Error in ==> mBisectoarei>calcBtn_Callback at 212
set(handles.rezInput, 'String', num2str(xr));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> mBisectoarei at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
#(hObject,eventdata)mBisectoarei('calcBtn_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
... and the entire code:
function varargout = mBisectoarei(varargin)
% MBISECTOAREI M-file for mBisectoarei.fig
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #mBisectoarei_OpeningFcn, ...
'gui_OutputFcn', #mBisectoarei_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 mBisectoarei is made visible.
function mBisectoarei_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 mBisectoarei (see VARARGIN)
% Choose default command line output for mBisectoarei
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mBisectoarei wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mBisectoarei_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;
function functieInput_Callback(hObject, eventdata, handles)
% hObject handle to functieInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of functieInput as text
% str2double(get(hObject,'String')) returns contents of functieInput as a double
functie = get(hObject,'String');
% save new value to global hObject for later use
handles.tb.functie = functie;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function functieInput_CreateFcn(hObject, eventdata, handles)
% hObject handle to functieInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function intervalA_Callback(hObject, eventdata, handles)
% hObject handle to intervalA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of intervalA as text
% str2double(get(hObject,'String')) returns contents of intervalA as a double
intA = str2num(get(hObject,'String'));
% save new value to global hObject for later use
handles.tb.intA = intA;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function intervalA_CreateFcn(hObject, eventdata, handles)
% hObject handle to intervalA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function intervalB_Callback(hObject, eventdata, handles)
% hObject handle to intervalB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of intervalB as text
% str2double(get(hObject,'String')) returns contents of intervalB as a double
intB = str2num(get(hObject,'String'));
% save new value to global hObject for later use
handles.tb.intB = intB;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function intervalB_CreateFcn(hObject, eventdata, handles)
% hObject handle to intervalB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function tolInput_Callback(hObject, eventdata, handles)
% hObject handle to tolInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of tolInput as text
% str2double(get(hObject,'String')) returns contents of tolInput as a double
tol = str2double(get(hObject,'String'));
% save new value to global hObject for later use
handles.tb.tol = tol;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function tolInput_CreateFcn(hObject, eventdata, handles)
% hObject handle to tolInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in calcBtn.
function calcBtn_Callback(hObject, eventdata, handles)
% hObject handle to calcBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% BEGIN mBisectoarei
f = inline(handles.tb.functie);
xl = handles.tb.intA;
xu = handles.tb.intB;
tol = handles.tb.tol;
if f(xu)*f(xl)<0
else
set(handles.rezInput, 'String', 'Interval gresit!');
end
for i=2:1000
xr=(xu+xl)/2;
if f(xu)*f(xr)<0
xl=xr;
else
xu=xr;
end
if f(xl)*f(xr)<0
xu=xr;
else
xl=xr;
end
xnew(1)=0;
xnew(i)=xr;
if abs((xnew(i)-xnew(i-1))/xnew(i))<tol,break,end
end
set(handles.rezInput, 'String', num2str(xr));
function rezInput_Callback(hObject, eventdata, handles)
% hObject handle to rezInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of rezInput as text
% str2double(get(hObject,'String')) returns contents of rezInput as a double
% --- Executes during object creation, after setting all properties.
function rezInput_CreateFcn(hObject, eventdata, handles)
% hObject handle to rezInput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
MATLAB GUIS cannot be run by directly opening .fig files. Take a look at this MathWorks link. Under the section labeled "Save the GUI Layout," find paragraph six (6). Under the screenshot, you will see a "Note:" that explains your problem.

save GUI figure in matlab

let us consider following program for graphical user interface
function varargout = quadratic(varargin)
% QUADRATIC MATLAB code for quadratic.fig
% QUADRATIC, by itself, creates a new QUADRATIC or raises the existing
% singleton*.
%
% H = QUADRATIC returns the handle to a new QUADRATIC or the handle to
% the existing singleton*.
%
% QUADRATIC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in QUADRATIC.M with the given input arguments.
%
% QUADRATIC('Property','Value',...) creates a new QUADRATIC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before quadratic_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to quadratic_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 quadratic
% Last Modified by GUIDE v2.5 23-Jul-2014 18:00:48
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #quadratic_OpeningFcn, ...
'gui_OutputFcn', #quadratic_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 quadratic is made visible.
function quadratic_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 quadratic (see VARARGIN)
% Choose default command line output for quadratic
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes quadratic wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = quadratic_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 edit1.
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
function b_Callback(hObject, eventdata, handles)
% hObject handle to b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of b as text
% str2double(get(hObject,'String')) returns contents of b as a double
% --- Executes during object creation, after setting all properties.
function b_CreateFcn(hObject, eventdata, handles)
% hObject handle to b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function c_Callback(hObject, eventdata, handles)
% hObject handle to c (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of c as text
% str2double(get(hObject,'String')) returns contents of c as a double
% --- Executes during object creation, after setting all properties.
function c_CreateFcn(hObject, eventdata, handles)
% hObject handle to c (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=str2num(get(handles.a,'String'));
b=str2num(get(handles.b,'String'));
c=str2num(get(handles.c,'String'));
d=b^2-4*a*c;
if (d>0)
X1=(-b+sqrt(d))/(2*a);
X2=(-b-sqrt(d))/(2*a);
set(handles.x1,'String',X1)
set(handles.x2,'String',X2)
elseif (d==0)
X1=(-b+sqrt(d))/(2*a);
set(handles.x1,'String',X1)
set(handles.x2,'String',X1)
else
set(handles.x1,'String','roots are complex')
set(handles.x2,'String','roots are complex')
end
function x1_Callback(hObject, eventdata, handles)
% hObject handle to x1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of x1 as text
% str2double(get(hObject,'String')) returns contents of x1 as a double
% --- Executes during object creation, after setting all properties.
function x1_CreateFcn(hObject, eventdata, handles)
% hObject handle to x1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function x2_Callback(hObject, eventdata, handles)
% hObject handle to x2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of x2 as text
% str2double(get(hObject,'String')) returns contents of x2 as a double
% --- Executes during object creation, after setting all properties.
function x2_CreateFcn(hObject, eventdata, handles)
% hObject handle to x2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a_Callback(hObject, eventdata, handles)
% hObject handle to a (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a as text
% str2double(get(hObject,'String')) returns contents of a as a double
% --- Executes during object creation, after setting all properties.
function a_CreateFcn(hObject, eventdata, handles)
% hObject handle to a (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
this program simple will allow to enter coefficients of quadratic equation and then solve equation and try to find roots,how can i take screenshot of GUI interface after this program?please help me,i want to save figure which occurs after running of this program,thanks in advance
One of the quick and dirty approaches
myGUI = quadratic;
% ......
% do something or wait until it's done...
% ......
print(myGUI, '-dpng', 'GUIOUT.png'); % save as .png
print(myGUI, '-djpeg', 'GUIOUT.jpg'); % save as .jpg
It will work fine if you only take a screenshot.
However, if you encounter the problem for which the output picture does not have the same size as the figure on your screen (especially when saving as pdf), you will probably have to implement solutions describled in
this article.
or even better using fig2file may work for you.

Matlab Gui: how to share datas among functions

I'm new to this forum and to matlab GUIs. I have this problem. I wanted to create a GUI which allows you to load data from an xlsx file and then I'd like to compute a GARCH model with this data. The problem I have is that I don't know how to pass this data to the function GARCH.
These are the functions I wrote. Hope you can help me.
function open(handles)
[FileName, PathName] = uigetfile('*.xlsx', 'Seleziona File dei Rendimenti');
A = xlsread(FileName, -1);
inVdati = A(:);
plot(inVdati, 'r');
legend('returns');
set(handles.Variance, 'Enable', 'on');
guidata(handles.figure1, handles) %saving values
and
function garch(handles)
handles = guidata(handles.figure1);
Sigmas = [];
spec = garchset('P', 1, 'Q', 1);
[Coeff, Errors, LLF, Innovations, Sigmas] = garchfit(spec, handles);
Can anyone of you tell me where I'm wrong?
Thank u :)
This is the whole code in case you need it:
function varargout = Var_final(varargin)
% VAR_FINAL MATLAB code for Var_final.fig
% VAR_FINAL, by itself, creates a new VAR_FINAL or raises the existing
% singleton*.
%
% H = VAR_FINAL returns the handle to a new VAR_FINAL or the handle to
% the existing singleton*.
%
% VAR_FINAL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VAR_FINAL.M with the given input arguments.
%
% VAR_FINAL('Property','Value',...) creates a new VAR_FINAL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Var_final_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Var_final_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 Var_final
% Last Modified by GUIDE v2.5 18-Jan-2014 22:34:22
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #Var_final_OpeningFcn, ...
'gui_OutputFcn', #Var_final_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 Var_final is made visible.
function Var_final_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 Var_final (see VARARGIN)
% Choose default command line output for Var_final
handles.figure1 = hObject;
% Update handles structure
guidata(hObject, handles);
handles.inVdati = [];
initialize_gui(handles);
% UIWAIT makes Var_final wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Var_final_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.figure1;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox2
% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
handles.dati.strutt = get(hObject, 'Value');
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton_calcola.
function pushbutton_calcola_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_calcola (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
calcola(handles)
% --- Executes on button press in pushbutton_reset.
function pushbutton_reset_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit4, 'value', 0)
% --------------------------------------------------------------------
function M_File_Callback(hObject, eventdata, handles)
% hObject handle to M_File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function AA_File_Callback(hObject, eventdata, handles)
% hObject handle to AA_File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function A_File_Callback(hObject, eventdata, handles)
% hObject handle to A_File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open(handles)
% --------------------------------------------------------------------
function TB_Reset_ClickedCallback(hObject, eventdata, handles)
% hObject handle to TB_Reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
gcbo(handles.figure1,handles)
% --------------------------------------------------------------------
function TB_Salva_ClickedCallback(hObject, eventdata, handles)
% hObject handle to TB_Salva (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
save_output(handles)
% --------------------------------------------------------------------
function TB_Apri_ClickedCallback(hObject, eventdata, handles)
% hObject handle to TB_Apri (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open(handles)
function initialize_gui(handles)
%questa funzione serve a definire i valori iniziali della GUI e quando
%viene premuto il pulsante reset
%struttura dati
handles.inputs.w=0;
handles.inputs.V_0=0;
handles.inputs.dist=0;
handles.inputs.alpha=0;
handles.dati.strutt=1;
handles.dati.strutt1=1;
handles.inputs.returns=0;
%struttura vettori delle funzioni risolutrici
handles.vettori.returns=[];
handles.vettori.sigmas=[];
handles.vettori.coeff=[];
handles.vettori.errors=[];
handles.vettori.LLF=[];
handles.vettori.Innovations=[];
handles.vettori.VAR=[];
%salvo le strutture create
guidata(handles.figure1, handles);
%passiamo i dati edit_text
set(handles.popupmenu1, 'Value', 1);
set(handles.popupmenu2, 'Value', 1);
set(handles.edit4, 'String', handles.inputs.V_0);
%nascondo assi all'apertura della GUI
set(handles.axes1, 'Visible', 'off');
set(handles.axes2, 'Visible', 'off');
set(handles.Variance, 'Enable', 'off');
cla;
%For Saving Outputs
function save_output(handles)
[Filename, Pathname] = uiputfile('.bmp', 'Save As');
Name = fullfile(Filename, Pathname);
imwrite(img, Filename, 'bmp');
[Filename, Pathname] = uiputfile('*.bmp', 'Save As');
if Pathname==0, return;
end
function garch(handles)
handles = guidata(handles.figure1, inVdati);
Sigmas = [];
spec = garchset('P', 1, 'Q', 1);
[Coeff, Errors, LLF, Innovations, Sigmas] = garchfit(spec, handles);
plot(Sigmas);
% --------------------------------------------------------------------
function E_File_Callback(hObject, eventdata, handles)
% hObject handle to E_File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function R_File_Callback(hObject, eventdata, handles)
% hObject handle to R_File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
initialize_gui(handles)
%caricare i rendimenti
function open(handles)
[FileName, PathName] = uigetfile('*.xlsx', 'Seleziona File dei Rendimenti');
A = xlsread(FileName, -1);
inVdati = A(:);
plot(inVdati, 'r');
legend('returns');
set(handles.Variance, 'Enable', 'on');
guidata(handles.figure1, inVdati) %saving values
% --- Executes on button press in Variance.
function Variance_Callback(hObject, eventdata, handles)
% hObject handle to Variance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
garch(handles)
function tabella_dati(handles)
inVdati = guidata(gcbo);
%figura principale
form1=figure('Position', [400,300,600,400], 'Name', 'Tabella Dati', ...
'NumberTitle', 'off', 'Color', [0.941 0.941 0.941], ...
'Resize', 'off', 'WindowStyle', 'normal');
%statit text
testo = uicontrol(form1, 'Style', 'text', 'Position', [250, 370, 100, 25], ...
'String', 'Dati Numerici');
%Table
cnames = {'Returns', 'Sigmas', 'Correlation', 'VaR'};
table = uitable('Data', 'inVdati', 'ColumnName', cnames,...
'Parent', form1, 'Position', [10 50 580 320]);
%Pulsanti
Esporta_Excel = uicontrol(form1, 'Style', 'pushbutton',...
'Position', [20, 10, 70, 25], 'String', 'Esporta in Excel', ...
'Callback', #esporta_excel_plot);
Esporta_txt = uicontrol(form1, 'Style', 'pushbutton', ...
'Position', [110, 10, 70, 25], ...
'String', 'Esporta txt', 'Callback', #esporta_txt_plot);
chiudi = uicontrol(form1, 'Style', 'pushbutton', 'Position', [200, 10, 70, 25], ...
'String', 'Chiudi', 'Callback', #chiudi_plot);
% --- Executes on button press in parametric.
function parametric_Callback(hObject, eventdata, handles)
% hObject handle to parametric (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of parametric
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
plot(guidata(gcbo));
axes(handles.axes2);
plot(Sigmas);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tabella_dati(handles)
You can save the variables that you wish to use between different functions by using the handles structure. For example if I wanted to pass the array A to another function:
% --- Executes on button press in push_button1.
function push_button1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
A = 0:0.1:2;
handles.array = A;
guidata(hObject,handles);
Now under another function, I could access what was A through:
% --- Executes on button press in push_button2.
function push_button2_Callback(hObject, eventdata, handles)
% hObject handle to push_button2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
B = handles.array;
or even pass it to another function by writing
output = some_func(handles.array)

How to extract data from a selected file by pressing a push button in GUI (MATLAB)?

This is the code of my GUI.
function varargout = hyst_gui(varargin)
% HYST_GUI MATLAB code for hyst_gui.fig
% HYST_GUI, by itself, creates a new HYST_GUI or raises the existing
% singleton*.
%
% H = HYST_GUI returns the handle to a new HYST_GUI or the handle to
% the existing singleton*.
%
% HYST_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HYST_GUI.M with the given input arguments.
%
% HYST_GUI('Property','Value',...) creates a new HYST_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before hyst_gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to hyst_gui_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 hyst_gui
% Last Modified by GUIDE v2.5 05-Jan-2014 16:19:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #hyst_gui_OpeningFcn, ...
'gui_OutputFcn', #hyst_gui_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 hyst_gui is made visible.
function hyst_gui_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 hyst_gui (see VARARGIN)
% Choose default command line output for hyst_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes hyst_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = hyst_gui_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 load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.*'},'Open Directory');
if isequal(filename,0) || isequal(pathname,0)
return
end
guidata(hObject, handles);
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes on button press in fit.
function fit_Callback(hObject, eventdata, handles)
% hObject handle to fit (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 pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (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 pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (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 pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (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 pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (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 pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
When I press load button, it shows a dialouge box for selecting files. After selecting files how can i extract datapoints written in the file, to plot a graph.
Your callback function to load the contents of the is load_Callback, I assume:
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.*'},'Open Directory');
if isequal(filename,0) || isequal(pathname,0)
return
end
guidata(hObject, handles);
uigetfile returns the name of the selected file and its path. It does not read or load it.
First, you need to open the file using fopen.
If the file extension is txt, you can use functions like textscan or fscanf.
If the file extension is dat, you can use fread.
Example for txt file:
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.*'},'Open Directory');
if isequal(filename, 0) || isequal(pathname, 0)
return
end
fileID = fopen(strcat(pathname, filename), 'r'); % read-only permission
handles.fileData = textscan(fileID,'%d');
guidata(hObject, handles);
Then, you can access handles.fileData from any of your callback functions.