在 Matlab 中,afigure
对应于一个单独的窗口。所以有两个数字将创建两个窗口。这是你想要的还是你想要在同一个窗口中的两个图?
如果您想要两个单独figure
的窗口,请尝试以下操作:
% create the 1st figure
fig1 = figure;
% create an axes in Figure1
ax1 = axes('Parent', fig1);
% create the 2nd figure
fig2 = figure;
% create an axes in Figure2
ax2 = axes('Parent', fig2);
for i = 1:n
...// calc matrix A
...// calc matrix B
% draw A in ax1
imagesc(A, 'Parent', ax1);
% draw B in ax2
imagesc(B, 'Parent', ax2);
% pause the loop so the images can be inspected
pause;
end
如果您想要一个窗口但有两个图表,您可以将循环之前的代码替换为:
%create the figure window
fig = Figure;
% create 2 side by side plots in the same window
ax(1) = subplot(211);
ax(2) = subplot(212);
% Insert loop code here