What Matt Fig said, plus: are you actually copying the number in (rather than saving it in a variable and passing the variable into the function)? Because that won't work for anything other than a figure handle. Figure handles are integers, but everything else is actually a hex reference (that appears as a double because, as the old joke goes, you can have any data type you want in MATLAB as long as it's a double -- no longer true, of course, but the remnants of that are seen in places, like HG). Anyway, the key point being that the handle isn't 123.0045 -- it's 123.0045blahblahblah. Any attempt to copy/paste the actual number will invariably get the floating point representation slightly off, and will therefore result in an incorrect hex reference, and that error message you love so much.
Bottom line, then: save handles as variables.
As Matt F alluded to in his answer, you can store handles as outputs from 99% of graphics function calls:
hf = figure;
ha = axes;
hp = plot(x,y,x,z);
etc. In this case, hf and ha will be scalar handles, hp will be a vector of 2 handles (one to each line object on the plot).
Use findobj to locate handles that you don't already have:
h = findobj('type','line')
And use the parent and children properties to navigate the hierarchy. For example, the above example could also be done:
hp = plot(x,y,x,z)
ha = get(hp(1),'parent')
hf = get(ha,'parent')
Best Answer