0

I have a picture that is plotted inside a figure in Matlab:

pic=imread('mypic.bmp');
figure(1)
h=image([1 1.2],fliplr([1 1.2],pic)

Now I want to move this figure to other locations inside the figure, with the method that is described in this question:

for i=2:3
    indices=[i i+.2];
    set(h,'?1',indices,'?2',fliplr(indices))
end

What do I have to fill in instead of ?1 and ?2? In the referred question, where the plot command is considered, they use XData and YData.

Community
  • 1
  • 1
Karlo
  • 1,630
  • 4
  • 33
  • 57

1 Answers1

1

Image objects (whether created with imshow, imagesc, or image) also have XData and YData properties.

xdata = get(h, 'XData');
ydata = get(h, 'YData');

They specify the x and y range of the image data. You can alter them the same way as you would for plot objects.

for k = 2:3
    indices = [k, k+0.2];
    set(h, 'XData', indices, 'YData', fliplr(indices));

    % Be sure to make it so the axes can display it
    set(gca, 'XLim', indices, 'Ylim', indices);
end
Suever
  • 64,497
  • 14
  • 82
  • 101