Passing an axes handlle to a function

8 views (last 30 days)
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

Walter Roberson
Walter Roberson on 19 Oct 2015
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)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!