From: Adrian on
Globals will work but arn't required. If you are using the handles to store vid (i.e., handles.vid) then you have to be sure to update the handles at the end of the function in which it is first stored to the handles, using:

% Choose default command line output for IS_Photorefraction
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

Another approach is to store anything you want to access in another function in the appdata. Such as the following:

% In your Opening_Fcn you can create the vid obj
% Create a video object
vidobj = videoinput('winvideo', 1, info.DeviceInfo(1,1).SupportedFormats{22});
% put the video object into the appdata
setappdata(gcf, 'VidObj', vidobj);

Then later you can retrieve the vidobj from the appdata in your other pushbutton functions or Delete_Fcn using:

% get the last image from the video object
vidobj = getappdata(gcf, 'VidObj');
close(VidObj);

The appdata is a powerful feature of MATLAB that permits versitility.
From: Adrian on
.....sorry, that last command should have been

close(vidobj); % .... not close(VidObj);