2016-11-24 2 views
0

私はMatlabを初めて使用していますが、私はこれらの2つのグラフの差をプロットすることに苦労しています。Matlab_ 2つのグラフの違いをプロット

% 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

私はよくあなたの問題を理解している場合は、2つのデータセット間違いを表す第3のプロットを作ることにしたいです。

何がしなければならないことは、あなたが求めるすべてのヒストグラムのための共通のビンを得ることです:

% 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

関連する問題