Finding the Euclidean Distance

I have values as
data2 =
[20x480 double] [20x480 double] [20x480 double] [20x480 double]
{ 1x8 cell } { 1x8 cell } { 1x8 cell } { 1x8 cell }
data1 =
[20x480 double]
{ 1x8 cell }
i want to match data2 and data1 by euclidean distance and if same values are present i want to display it,plz help

1 件のコメント

Matt J
Matt J 2012 年 12 月 29 日
編集済み: Matt J 2012 年 12 月 29 日
What's in the 1x8 cells?
What do you want displayed? The data? The column numbers of data2 which agree with data1?
When are the values considered "the same"? When the Euclidean distance = 0 precisely or is there some tolerance>0? If the tolerance=0, why care about the Euclidean distance at all? Why not just use ISEQUAL, as in my Answer below?

サインインしてコメントする。

 採用された回答

Matt J
Matt J 2012 年 12 月 29 日

1 投票

find(arrayfun(@(i) isequal(data2(:,i),data1), 1:size(data2,2) )),

8 件のコメント

Pat
Pat 2013 年 1 月 2 日
am getting
ans =
Empty matrix: 1-by-0
José-Luis
José-Luis 2013 年 1 月 2 日
It means that no data is equal.
Pat
Pat 2013 年 1 月 2 日
i checked by have one value
>> data2
data2 =
[20x480 double] [20x480 double]
{ 1x8 cell } { 1x8 cell }
>> data1=data2
data1 =
[20x480 double] [20x480 double]
{ 1x8 cell } { 1x8 cell }
>> find(arrayfun(@(i) isequal(data2(:,i),data1), 1:size(data2,2) )),
ans =
Empty matrix: 1-by-0
José-Luis
José-Luis 2013 年 1 月 2 日
編集済み: José-Luis 2013 年 1 月 2 日
What is inside data1 and data2? I have a hard time understanding how Matt's code is computing distances.
Image Analyst
Image Analyst 2013 年 1 月 2 日
Perhaps the FAQ applies here.
Matt J
Matt J 2013 年 1 月 2 日
編集済み: Matt J 2013 年 1 月 2 日
@Pat,
data1=data2 is not a valid example of your original problem description. In your problem as you originally posted it, data1 had only one column. When I modify your example as follows, I get the expected result
data2={rand(20,480),rand(20,480);
num2cell(ones(1,8)), num2cell(ones(1,8))};
data1=data2(:,2);
find(arrayfun(@(i) isequal(data2(:,i),data1), 1:size(data2,2) ))
ans =
2
If this is not what you want, edit your question clarifying the form of the data and also, include a numerical example of desired input and output.
Pat
Pat 2013 年 1 月 3 日
if data1 has different values i get empty matrix
i want to display data is present ,how can i check the answer if it is empty matrix or not and display it
so how i can display it as "data is present".
Walter Roberson
Walter Roberson 2013 年 1 月 3 日
isempty()

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

Pat
2012 年 12 月 29 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by