how to make passing parametes between GUI and *.m files

%================== in my gui file
mygui.m
-------
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.avi';'*.mpeg'}, 'Pilih Video');
set(handles.edit1,'string',[pathname filename]);
guidata(hObject, handles);
%call my 'myfile.m'
mymfile
%================== in my *.m file
mymfile.m
-------
function obj = setupSystemObjects()
urlfiles = get(handles.edit1,'string');
obj.reader = vision.VideoFileReader(urlfiles);
how to passing '[pathname filename]' in 'handels.edit1' to variabel 'urlfiles' in my 'mymfiles.m' cause i still get error.
"The class "handles" is undefined. Perhaps Java is not running."

Réponses (1)

Fitroh - why not just pass the list of videos to your setupSystemObjects function (which is presumably saved to a file called setupSystemObjects.m and not in myfile.m) as an input parameter? Change the signature and body of this function to
function obj = setupSystemObjects(videoFiles)
obj.reader = vision.VideoFileReader(videoFiles);
% etc.
and then call this function from your callback as
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.avi';'*.mpeg'}, 'Pilih Video');
videoFiles = [pathname filename];
set(handles.edit1,'string', videoFiles);
setupSystemObjects(videoFiles);
Try the above and see what happens! The alternative is to use global variables, but that is something that can be avoided here.

Catégories

En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by