MATLAB: Handles in Matlab Guide

guiguidehandles

I am having a difficult time understanding use of handles
in MATLAB's guide. WHEN TO USE THEM?
For example, this is MATLAB's example how to use MATLAB Guide:
handles.peaks = peaks(35);
[x, y] = meshgrid(-8:.5:8)
handles.current_data = handles.peaks
surf(handles.current_data)
I guess we are using handles to pass data to the functions.
I'm confused.
Thanks,
Amanda

Best Answer

That's correct. That's one of the ways to make an otherwise local variable into a global variable so that they can be seen in other functions. Most of the other ways are discussed here: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F In your case you don't need to do that unless you're going to need those variables later, in a different function or callback function.
Related Question