What are handles in Matlab and why they are used?
Consider that you need to plot multiple graphs in Matlab. For example you might want to have one figure to plot voltage vs time and another figure for temperature vs time. From the Matlab software point of view it needs to keep track of each figures.. And in order to do so different handles for the same figure object are created. Now handle is an instance of figure object. For matlab to know which figure is used for which purpose we need to supply it with variable object holder. This variable object holder is called handle or are handles.
Consider the following:
>> f = figure; >> g = figure; >> f f = Figure (1) with properties: Number: 1 Name: '' Color: [0.9400 0.9400 0.9400] Position: [403 246 560 420] Units: 'pixels' Show all properties >> g g = Figure (2) with properties: Number: 2 Name: '' Color: [0.9400 0.9400 0.9400] Position: [403 246 560 420] Units: 'pixels' Show all properties
Here we created two instances f and g of the same object figure. In other words we created two handles f and g for the same figure object. Now in this way matlab keeps track of which figure object is being accessed and modified. As you can see the properties of each f and g handles are different.
So handles in Matlab software are instances of object used to keep track of those object instances.
See Object oriented programming with Matlab and Creating and Modifying Handles to an object in Matlab