2016-11-24 207 views
0

我是Matlab新手,我正在努力绘制这两个图形之间的区别(从另一个图形中减去一个图形)......任何人都可以帮助我吗?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

如果我深知你的问题,你想使代表两个数据集之间的差的第三情节。

你所要做的就是让普通箱为你计算出直方图:

% 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; 
+0

谢谢@beesleep!它帮助了很多! – Mraquel