我是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');
答案 0 :(得分:0)
如果我理解你的问题,你想制作第三个图,表示两个数据集之间的差异。
您需要做的是为您计算的所有直方图获取公共区域:
% 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;