Matlab中的imagesc()未显示等轴

Matlab中的imagesc()未显示等轴,image,matlab,plot,scale,axis,Image,Matlab,Plot,Scale,Axis,我使用以下代码行来绘制图像: for t=1:subplotCol subplot(subplotRow,subplotCol,t) imagesc([1 100],[1 100],c(:,:,nStep*t)); colorbar xlabel('X-axis') ylabel('Y-axis') title(['Concentration profile at t_{',num2str(nStep*t),'}']) subplot(s

我使用以下代码行来绘制图像:

for t=1:subplotCol
    subplot(subplotRow,subplotCol,t)
    imagesc([1 100],[1 100],c(:,:,nStep*t));
    colorbar
    xlabel('X-axis')
    ylabel('Y-axis')
    title(['Concentration profile at t_{',num2str(nStep*t),'}'])

    subplot(subplotRow,subplotCol,subplotCol+t)
    hold on;
    plot(distance,gamma(:,1,t),'-ob');
    plot(distance,gamma(:,2,t),'-or');
    plot(distance,gamma(:,3,t),'-og');
    xlabel('h');ylabel('\gamma (h)');
    legend(['\Theta = ',num2str(theta(1))],...
        ['\Theta = ',num2str(theta(2))],['\Theta = ',num2str(theta(3))]);
end
我得到以下带有图像的子图:

正如您所见,第一行中的图像现在在X轴和Y轴上的比例相等(Y轴比X轴长),即使第一行中的每个图像的图像矩阵大小为100x100


有人能帮助我如何使第一行的图像看起来像正方形而不是我目前得到的矩形吗。谢谢。

使用轴的
dataAspectRatio
属性,并将其设置为
[1]

%# create a test image
imagesc(1:10,1:10,rand(10))


另一种方法是使用命令
axis equal

关于不同对象的大小,您可以设置图形上每个轴的确切位置,例如第一次使用:
子批次(2,2,1);集合(gca,'Position',[0.05 0.05 0.4 0.4])

乔纳斯:谢谢你的回答。使用建议的命令会在子绘图上显示一个图像,但随后会显示一个错误,即
???使用==>设置时出错“image”类中没有“dataAspectRatio”属性。
。我不知道为什么它会在第一张图片之后出现,但对于第一张图片本身却没有。你知道为什么吗?对不起,那是我的错。我使用imagesc()中的句柄,而不是您建议的子批中的句柄。还有一个问题:这些图片现在是正方形的,但它们的大小比第二排的要小得多。您可以查看问题更新以查看相对大小。您好。使用
set(gca,'Position',[0.05 0.05 0.4 0.4])
将第一行的图像与第二行的第一个图像重叠。换句话说,由于图像的重叠,图像位置的设置被改变。
%# you should use the handle returned by subplot
%# instead of gca
set(gca,'dataAspectRatio',[1 1 1])