Here is my error,how should i fix the problem?Help!!!!!

4 次查看(过去 30 天)
Unrecognized function or variable 'pushbutton1_Callback'.
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Gui_Main (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Gui_Main('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
95 feval(varargin{:});
this is my gui code
function varargout = Gui_Main(varargin)
% GUI_MAIN MATLAB code for Gui_Main.fig
% GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
% singleton*.
%
% H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
% the existing singleton*.
%
% GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_MAIN.M with the given input arguments.
%
% GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Gui_Main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Gui_Main_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_Main
% Last Modified by GUIDE v2.5 12-Dec-2021 23:25:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
'gui_OutputFcn', @Gui_Main_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 Gui_Main is made visible.
function Gui_Main_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_Main (see VARARGIN)
% Choose default command line output for Gui_Main
handles.output = hObject;
handles.Result = [];%
handles.File = [];%
% Update handles structure
guidata(hObject, handles);%
clc; warning off all;
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Gui_Main_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 pushbutton1.
% --- Executes on button press in pushbuttonOpenFile.
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonOpenFile (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({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
'*.*','All Files' },'load image',...
fullfile(pwd, 'images'));
if isequal(filename, 0) || isequal(pathname, 0)
return;
end
I = imread(fullfile(pathname, filename));
Result = Process_Main(I);
handles.File = fullfile(pathname, filename);
handles.Result = Result;
guidata(hObject, handles);
InitAxes(handles)
axes(handles.axes1); imshow(handles.Result.Image); title('orginal image')

回答(1 个)

Walter Roberson
Walter Roberson 2021-12-20
Inside Gui_Main.fig there is a graphics object that asks Gui_Main to execute function pushbutton1_Callback. However, your Gui_Main.m file does not define any function named pushbutton1_Callback . It does define a function named pushbuttonOpenFile_Callback but that does not necessarily have anything to do with pushbutton1_Callback .
I suspect that you tried to rename a pushbutton callback function by just editing the Gui_Main.m code . You cannot do that: you have to use GUIDE to change the callback it associates with the button.
There is state information stored in the .fig file that is not stored in the .m file; you need to work with the two together.
For the moment, you could experiment by adding
function pushbutton1_Callback(hObject, eventdata, handles)
pushbuttonOpenFile_Callback(hObject, eventdata, handles);
end
This would have pushbutton1_Callback just immediately invoke pushbuttonOpenFile_Callback .
... Assuming that is the desired behaviour.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by