can anyone fix this issue?
1 次查看(过去 30 天)
显示 更早的评论
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)plz('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
and my code is
function varargout = plz(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @plz_OpeningFcn, ...
'gui_OutputFcn', @plz_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 plz is made visible.
function plz_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for plz
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes plz wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = plz_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.
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)
[c, d] = uigetfile({'*.*' , 'all files'});
imj = imread([c , d]);
s = imshow(imj , 'parent' , handles.axes1);
imshow(s);
采纳的回答
Walter Roberson
2016-5-1
The order of outputs from uigetfile is file name first and then directory. Your use of [c , d] has the components in the wrong order.
What you should use instead of [c, d] is fullfile(d, c)
filename = fullfile(d, c);
imj = imread(filename);
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!