- Use the Import Tool in MATLAB to import the data into MATLAB workspace, say as a Matrices. Thus importing first file would result in a variable "data1" and second file would result in "data2".
- Assuming the files are of nx2 dimension (containing x coordinate as 1st column and y coordinate as 2nd column), the variables will also be nx2.
- Find the difference vector between the two variables.
- Use (dot-exponent) operator to raise it to required power.
- Use the 'sum' function along 2nd dimension and then 'sqrt' function to get the euclidean distance.
how can i find the eucledian disatnce using KNN algorithm for the set of large n*2 matrix for the following kind of dataset
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
1.739631e-01 6.457726e-01
1.716590e-01 6.457726e-01
1.693548e-01 6.457726e-01
1.647465e-01 6.457726e-01
so on..
These are stored in a .txt file, but how do I find the Euclidean distance for the current sample xy coordinate with other stored .txt 5 files to recognize the similar sample or min distance? I am not getting how to find this. Please can some one help me?
0 comentarios
Respuestas (1)
Kushagr Gupta
el 8 de Nov. de 2016
I understand that you want to find euclidean distance between xy coordinates contained in different files.
Following is one way in which it can be done:
In code it can be done in a single line for two files and can be applied to multiple files using a loop:
>> dist = sqrt(sum((data1-data2).^2),2))
Hope this helps!
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!