MATLAB: How to change current figure handle

axesgcfhandles

I want to get image from a handle named axes1 in my code. How can I use gcf to get that image? I tried this but it is not working:
axes(handles.axes1);
train_image=getimage(gcf);
The image I am getting is from another axes(not axes1). Please help.

Best Answer

train_image = getimage(handles.axes1)