Passing an axes handlle to a function

I have created a function in which I want to be able to take an image from an axes1 component and redraw on another axes component...with this target axes component being passed as n argument. This is my attempt:
The function:
function rescaleImage(handles,str)
%Get image on axes1
axes(handles.axes1)
image1=getimage(handles.axes1);
%Create handle for new placement of image
%Use str argument to pass the axes handle.
str2func(str)
imshow(image1,[])
Calling the function to redraw the image onto axes3.
rescaleImage(handles,'handles.axes3')
There is no error message, but the image does not redraw on axes3.

 Accepted Answer

function rescaleImage(handles,str)
%Get image on axes1
axes(handles.axes1)
image1 = getimage(handles.axes1);
%Create handle for new placement of image
%Use str argument to pass the axes handle
imshow(image1,[], 'Parent', handles.(str))
and instead of passing 'handles.axes3' pass 'axes3'

More Answers (0)

Asked:

on 19 Oct 2015

Commented:

on 19 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!