Matlab 绘制两个图之间的差异

Matlab_ Plot the difference between two graphs

我是 Matlab 的新手,我正在努力绘制这两个图表之间的差异(从一个图表中减去另一个图表)...任何人都可以帮助我吗?

% 2D plot of original target locations
X= double(xCoords);
Y= double(yCoords);
originalvalues = hist3([X(:) Y(:)],[30 40]);
imagesc(originalvalues)
contourf(originalvalues)
c= colorbar;
c.Label.String = 'Initial location';
axis equal
axis xy
xlabel('endCoordinatesx');
ylabel('endCoordinatesy');
title('2D Map of Original locations');

% 2D plot of final target locations
Xf= Design.endCoordinatesX;
Yf= Design.endCoordinatesY;
values = hist3(double([Xf(:) Yf(:)],[30 40]));
imagesc(values)
contourf(values)
c= colorbar;
c.Label.String = 'Final location';
axis equal
axis xy
xlabel('endCoordinatesx');
ylabel('endCoordinatesy');
title('2D Map of final locations');

如果我理解你的问题,你想制作第三个图来表示两个数据集之间的差异

您需要做的是为您计算的所有直方图获取公共分箱:

% find common centers for the two datasets
[~, centers] = hist3(cat(2,[X(:) ; Xf(:)],...
                           [Y(:) ; Yf(:)]),...
                     [30 40]);

% then you can calculate the histogram for each set of data : 
originalvalues = hist3([X(:)  Y(:) ], centers);
values         = hist3([Xf(:) Yf(:)], centers);

% finaly, compute the difference between the two (now the bins are "aligned")
differenceValue = values - originalvalues;