can anyone fix this issue?
1 view (last 30 days)
Show older comments
sana saleeme
on 1 May 2016
Commented: Walter Roberson
on 1 May 2016
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);
Accepted Answer
Walter Roberson
on 1 May 2016
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 Comments
More Answers (0)
See Also
Categories
Find more on Environment and Settings 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!