I am trying to save n number of graphic handles to a (cell)array in a loop. (so that I can change each item visibility later using array index)
The problem I face:
Every time the loop iterate and add a new element to the array, element in the previous index is becoming invalid. (eg: when h_circles(2) is added, h_circles(1) handle values are lost)
Finally When I try to access or modify any handle in h_circles , "invalid or deleted handle" error is occurring.
IS cell array the correct method to save graphic handles for later use?? If not how to store handles for later use?
Here is the sample code snippet:
h_circles(1, i) = {drawcircle(x, y, r)};
function h = drawcircle(x,y,r)