我會回答我的問題,這是我做了什麼。我希望這也能幫助別人。
a=[
1 0 0 0;
1 1 0 0;
0 0 0 0;
0 0 0 0];
aa = a;
ac = aa;
b=[NaN NaN NaN NaN];
a = [a;b];
b = [b NaN];
b = b.';
a = [a b];
I = imread('redirt.jpg');
J = imresize(I, 3, 'nearest');
[x , y] = size(aa);
delete(findall(gcf,'Tag','8puzzle'))
pos=get(gca,'position'); % getting the position
% calculating position
width=pos(3)/(y);
height =pos(4)/(x);
Cmap = [1 1 1];
colormap(Cmap);
pcolor(a)
axis off
% loop over the positions/cells you want to place image
for i=1:x
for j=1:y
if(aa(i,j) == 1)
% image position
axes('pos',[pos(1)+width*(i-1),pos(1)+height*(j-1),width,height], 'Tag','8puzzle');
% Show image
imshow(J)
end
if (i == 4 && j == 4)
axes('pos',[pos(1)+width*(i-1),pos(1)+height*(j-1),width,height], 'Tag','8puzzle');
% Show image
imshow('vacum.jpg')
end
end
end
set(gca, 'Ydir', 'reverse');
的圖像重疊的細胞只是一個小但是,它是不與顯示干擾。
[**'subplot' **](https://www.mathworks.com/help/matlab/ref/subplot.html),無? –
什麼是'subplot'?感謝您的鏈接,我現在會嘗試。 – Jam1