MATLAB: Copy figure (short, probably some unset variable)

copyhandles

I am using R2019b Update 3 on a linux box. My figures have everything under edit from "undo" to "delete" grayed out. I can't use them in gui. Key strokes don't work either.
So I found:
h=plot(index,data)
This produces the following from matlab:
h =
2×1 Line array:
Line
Line
Then
hgexport(h,'-clipboard')
produces:
Error using hgexport
First argument must be a handle to a figure.
Do I have something setup wrong in the install? Ho come I cannot copy a figure? I can export setup as a jpg file of the figure.
Thanks in advance.

Best Answer

h is the variable name, not the handle. To get the handle of the current figure you can do:
h_handle = gcf; % get current figure
hgexport(h_handle, '-clipboard');
For more general cases, see the accepted answer to this question: How do I get the handles of all open figures in MATLAB