Maybe you need to specify the axis in which you are placing your image or data. The imshow
command allows you specify the axes to use for displaying images with the Parent
parameter.
Combine this with the fact that subplot
returns a handle to the axis it creates and you have.
h = subplot(m,n,i) %# create a subplot axes
imshow(img,'Parent',h) %# display an image in the previously created axis
Assuming you can pass information between the two sets of code you would need to retrieve the handle to the axis you want the image to show up in and use that handle in the call to imshow
. Here is an example
hFig = figure;
h(1) = subplot(2,2,1)
h(2) = subplot(2,2,2)
setappdata(hFig,'axisHandles',h) %# stores the axes handles in appdata of the figure
....
Now when you want to show some an image in the first figure you can do the following assuming you know the handle to each of your figure windows.
h=getappdata(hFig,'axisHandles')
imshow(img,'Parent',h(1))