比较matlab中的图 [英] Compare Plots in matlab

查看:147
本文介绍了比较matlab中的图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在matlab中有两个绘图,其中绘制了x和y坐标。如果我有这两个地块,是否可以比较地块是否匹配?我可以通过数字来判断它们的匹配程度吗?



请注意,图表可能会右移/左移/上移/下移(打开轴线不是问题),缩放/旋转(我也想知道它是否偏斜,但现在,它不是必须的)。



不需要测试颜色元素,颜色倒置和其他复杂的图形属性,而不是上面提到的基本元素。



如果matlab不够用,我会欢迎其他工具。

请注意,我不能简单地把x和y值的绝对差异。我可以获得x绝对差异平均和y绝对差异,然后平均但我需要一个组合错误。我需要比较图表。



要比较的图表



编辑



直接相关不适用于我。



对于不同的数据集:我得到了.94相关性。对于给定的数据,这是非常高的。注意到一个数据波动比其他数据更少和更快。

解决方案

您可以使用此代码访问绘制的数据

  x = 10:100; 
y = log10(x);
plot(x,y);

h = gcf;
axesObjs = get(h,'Children'); %轴处理
dataObjs = get(axesObjs,'Children'); %处理轴中的低级图形对象
objTypes = get(dataObjs,'Type');低级图形对象的类型
xdata = get(dataObjs,'XData');来自低级别grahics对象的%数据
ydata = get(dataObjs,'YData');

然后,您可以在xdata和ydata之间进行关联,或者进行任何比较。系数R表示百分比匹配。

  [R,P] = corrcoef(xdata,ydata); 

您还可能想要比较图形电流轴的轴限制。例如

  R =(diff(get(h_ax1,'XLim'))/ diff(get(h_ax2,'XLim' )))+ ... 
(diff(get(h_ax1,'YLim'))/ diff(get(h_ax2,'YLim')))

其中h_ax1是第一个ax和h_ax2的句柄。在这里,你将比较(XLim + YLim)的值。尽管可能与不同的gca属性进行比较,但它们确实很庞大。

编辑 p

要比较两组点,您可以使用除分析关系之外的其他指标。我想到距离或收敛性,例如 Hausdorff距离。一个脚本可在这里在matlab central中找到。我用这样的距离来比较字母形状。在维基百科页面中,应用部分非常重要(边缘检测器适用于较厚的形状,但可能与您的特定问题无关)。

I have two plots in matlab where in I have plotted x and y coordinates. If I have these two plots, is it possible to compare if the plots match? Can I obtain numbers to tell how well they match?

Note that the graphs could possibly be right/left/up/down shifted in plot (turning axis off is not problem), scaled/rotated (I would also like to know if it is skewed, but for now, it is not a must).

It will not need to test color elements, color inversion and any other complicated graphic properties than basic ones mentioned above.

If matlab is not enough, I would welcome other tools.

Note that I cannot simply take the absolute difference of x- and y- values. I could obtain x-absolute difference average and y-absolute difference and then average but I need a combined error. I need to compare the graph.

Graphs to be compared.

EDIT

Direct Correlation does not work for me.

For a different set of data: I got .94 correlation. This is very high for given data. noticing that one data is fluctuating less and faster than other.

解决方案

You can access the plotted data with this code

x = 10:100;  
y = log10(x);  
plot(x,y);  

h = gcf;  
axesObjs = get(h, 'Children'); %axes handles  
dataObjs = get(axesObjs, 'Children'); %handles to low-level graphics objects in axes  
objTypes = get(dataObjs, 'Type'); %type of low-level graphics object  
xdata = get(dataObjs, 'XData'); %data from low-level grahics objects  
ydata = get(dataObjs, 'YData');  

Then you can do a correlation between xdata and ydata for example, or any kind of comparison. The coefficient R will indicate a percent match.

[R,P] = corrcoef(xdata, ydata);

You would also be interested in comparing the axes limits in the graphical current axes. For example

R = ( diff(get(h_ax1,'XLim')) / diff(get(h_ax2,'XLim')) ) + ...
( diff(get(h_ax1,'YLim')) / diff(get(h_ax2,'YLim')) )

where h_ax1 is the handle of the first axe and h_ax2 for the second one. Here, you will have a comparison between values of (XLim + YLim). The possible comparisons with different gca properties are really vast though.

EDIT

To compare two sets of points, you may use other metrics than analytical relationship. I think of distances or convergences such as the Hausdorff distance. A script is available here in matlab central. I used such distance to compare letter shapes. In the wikipedia page, the 'Applications' section is of importance (edge detector for thick shapes, but it may not be pertinent to your particular problem).

这篇关于比较matlab中的图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆