Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在diff图片matlab上绘制图形_Matlab_Visualization - Fatal编程技术网

如何在diff图片matlab上绘制图形

如何在diff图片matlab上绘制图形,matlab,visualization,Matlab,Visualization,我有一个matlab程序,我需要在两个单独的数字显示2个不同的图片 我目前的尝试是: fig = figure; for i = 1:n ...// calc matrix A ...// calc matrix B imagesc(A); imagesc(B); end 此代码在同一个图上显示两个图像,但我需要在图1上显示imagesc(A)(并在每次迭代时更改),在图2上显示imagesc(B)(并在每次迭代时更改) 这可能吗?如果是这样的话,怎么做?您可以使用fi

我有一个matlab程序,我需要在两个单独的数字显示2个不同的图片

我目前的尝试是:

fig = figure;
for i = 1:n
   ...// calc matrix A
   ...// calc matrix B
   imagesc(A);
   imagesc(B);
end
此代码在同一个图上显示两个图像,但我需要在图1上显示
imagesc(A)
(并在每次迭代时更改),在图2上显示
imagesc(B)
(并在每次迭代时更改)

这可能吗?如果是这样的话,怎么做?

您可以使用figure()函数在matlab将绘制图形/图像的图形窗口之间切换:

   for i = 1:n
       ...// calc matrix A
       ...// calc matrix B

       figure(1);
       imagesc(A);

       figure(2);
       imagesc(B);

    end
您可以使用figure()函数在matlab将绘制图形/图像的图形窗口之间切换:

   for i = 1:n
       ...// calc matrix A
       ...// calc matrix B

       figure(1);
       imagesc(A);

       figure(2);
       imagesc(B);

    end

在Matlab中,图对应于一个单独的窗口。因此,拥有两个图形将创建两个窗口。这是您想要的还是希望在同一窗口中有两个绘图

如果您想要两个独立的
窗口,请尝试以下操作:

% 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

在Matlab中,图对应于一个单独的窗口。因此,拥有两个图形将创建两个窗口。这是您想要的还是希望在同一窗口中有两个绘图

如果您想要两个独立的
窗口,请尝试以下操作:

% 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

你能不能给你的答案加上一些解释,让它更有帮助?这将是一种缓慢的实现方式。您最好使用第一种方法,手动跟踪图形句柄。您是否应该在答案中添加一些解释,以使其更有帮助?这将是一种缓慢的实现方式。最好使用第一种方法,手动跟踪图形句柄。