How to remove thi GUI error?
2 views (last 30 days)
Show older comments
Hello everyone
I'm trying to call my GUI code from matlab's main script where I'm setting there buttons' values there
but I keep receiving so many errors and each time I correct one another one pops out
My GUI script name is Compare.m and the figure's name is Compare.fig
Please help me correct the errors
Here's the name script's code:
h = Compare;
guidata(h,handles);
set(handles.pushbutton1_ButtonDownFcn, 'Value', a)
set(handles.pushbutton2_ButtonDownFcn, 'Value', '002.png')
set(handles.pushbutton3_ButtonDownFcn, 'Value', '003.png')
set(handles.pushbutton4_ButtonDownFcn, 'Value', '004.png')
set(handles.pushbutton5_ButtonDownFcn, 'Value', '005.png')
callback = get(handles.pushbutton6_ButtonDownFcn, 'Callback');
callback = strrep(callback, 'gcbo', 'handles.figure1');
eval(callback);
The errors I get here are either :
- Reference to non-existent field 'pushbutton1_ButtonDownFcn'.
- Undefined function or variable 'handles'.
My GUI code is:
function varargout = Compare(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Compare_OpeningFcn, ...
'gui_OutputFcn', @Compare_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
function Compare_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = Compare_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
function pushbutton2_Callback(hObject, eventdata, handles)
function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.png','Select an image');
global I1;
I1 =imread(strcat(PathName,FileName));
axes(handles.axes1);
imshow(I1);
function pushbutton3_Callback(hObject, eventdata, handles)
function pushbutton4_Callback(hObject, eventdata, handles)
function pushbutton5_Callback(hObject, eventdata, handles)
function pushbutton6_Callback(hObject, eventdata, handles)
function pushbutton5_ButtonDownFcn(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.png','Select an image');
global I2;
I2 =imread(strcat(PathName,FileName));
axes(handles.axes3);
imshow(I2);
function pushbutton6_ButtonDownFcn(hObject, eventdata, handles)
global I1;
global I2;
global I3;
global I4;
global I5;
Imaged1 = im2double(I1);
Imaged2 = im2double(I2);
Imaged3 = im2double(I3);
Imaged4 = im2double(I4);
Imaged5 = im2double(I5);
Imageg1 = rgb2gray(Imaged1);
Imageg2 = rgb2gray(Imaged2);
Imageg3 = rgb2gray(Imaged3);
Imageg4 = rgb2gray(Imaged4);
Imageg5 = rgb2gray(Imaged5);
hn1 = imhist(Imageg1)./numel(Imageg1);
hn2 = imhist(Imageg2)./numel(Imageg2);
hn3 = imhist(Imageg3)./numel(Imageg3);
hn4 = imhist(Imageg4)./numel(Imageg4);
hn5 = imhist(Imageg5)./numel(Imageg5);
f1 = sum((hn1 - hn2).^2);
f2 = sum((hn1 - hn3).^2);
f3 = sum((hn1 - hn4).^2);
f4 = sum((hn1 - hn5).^2);
set(handles.text2,'String',f1)
set(handles.text3,'String',f2)
set(handles.text4,'String',f3)
set(handles.text5,'String',f4)
function pushbutton3_ButtonDownFcn(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.png','Select an image');
global I3;
I3 =imread(strcat(PathName,FileName));
axes(handles.axes4);
imshow(I3);
function pushbutton4_ButtonDownFcn(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.png','Select an image');
global I4;
I4 =imread(strcat(PathName,FileName));
axes(handles.axes5);
imshow(I4);
function pushbutton2_ButtonDownFcn(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.png','Select an image');
global I5;
I5 =imread(strcat(PathName,FileName));
axes(handles.axes6);
imshow(I5);
Please Help me
Thank You
0 Comments
Answers (1)
Walter Roberson
on 6 May 2015
For your second line, instead of
guidata(h,handles);
use
handles = guidata(h);
0 Comments
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!