Why error to GUI?

1 回表示 (過去 30 日間)
Marquel Dwi Putranto
Marquel Dwi Putranto 2016 年 3 月 3 日
function varargout = SmarthomeIsyarat(varargin)
% SMARTHOMEISYARAT M-loadvideo for SmarthomeIsyarat.fig
% SMARTHOMEISYARAT, by itself, creates a new SMARTHOMEISYARAT or raises the existing
% singleton*.
%
% H = SMARTHOMEISYARAT returns the handle to a new SMARTHOMEISYARAT or the handle to
% the existing singleton*.
%
% SMARTHOMEISYARAT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SMARTHOMEISYARAT.M with the given input arguments.
%
% SMARTHOMEISYARAT('Property','Value',...) creates a new SMARTHOMEISYARAT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SmarthomeIsyarat_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SmarthomeIsyarat_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 SmarthomeIsyarat
% Last Modified by GUIDE v2.5 03-Mar-2016 12:41:14
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SmarthomeIsyarat_OpeningFcn, ...
'gui_OutputFcn', @SmarthomeIsyarat_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 SmarthomeIsyarat is made visible.
function SmarthomeIsyarat_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 SmarthomeIsyarat (see VARARGIN)
% Choose default command line output for SmarthomeIsyarat
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes SmarthomeIsyarat wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = SmarthomeIsyarat_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 during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
hback = axes('units','normalized','position',[0 0 1 1]);
uistack(hback,'bottom');
[back map]=imread('backgroundFilkom.png');
image(back)
colormap(map)
set(hback,'handlevisibility','off','visible','off')
% --- Executes on button press in loadvideo.
function loadvideo_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
[namafile,direktori]=uigetfile({'*.avi';'*.mov';'*.mp4';'*.mpeg'},'Buka Gambar')
if isequal(namafile,0)
return;
end
eval(['cd ''' direktori ''';']);
I=imread(namafile);
set(proyek.figure1,'CurrentAxes',proyek.axes1);
set(imshow(I));
set(proyek.figure1,'Userdata',I);
set(proyek.axes1,'Userdata',I);
Why error???
Error in ==> SmarthomeIsyarat>loadvideo_Callback at 92
I=imread(namafile);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> SmarthomeIsyarat at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)SmarthomeIsyarat('loadvideo_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 3 日
Do not use eval(), especially not for this purpose.
[namafile, direktori] = uigetfile({'*.avi';'*.mov';'*.mp4';'*.mpeg'},'Buka Gambar')
if isequal(namafile,0)
return;
end
filename = fullfile(direktori, namafile);
if ~exist(filename, 'file')
warndlg( sprintf('Failed to find file "%s"', filename) ); %odd !
return
end
I = imread(filename);
  1 件のコメント
Marquel Dwi Putranto
Marquel Dwi Putranto 2016 年 3 月 6 日
Thank you Mr walter

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by