hi , i have two graph one is fixed and the other one is changing (64 graphe )i want to find the most closest graphe to the fixed one .please help??
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
nihed sboui
el 27 de Feb. de 2020
Comentada: Walter Roberson
el 28 de Feb. de 2020
hi , i have two graph one is fixed and the other one is changing i want to find the most close graphe to the fixed one .please help??
2 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Feb. de 2020
One approach is to use https://www.mathworks.com/help/stats/knnsearch.html knnsearch . That would get you a list of the closest point in the fixed to each point in the varying, and you could then find the minimum distance from there.
Another approach, assuming Euclidean distance:
dsq = bsxfun(@minus, xvarying(:), xfixed(:).').^2 + bsxfun(@minus, yvarying(:), yfixed(:).').^2;
mindsq = min(dsq(:));
[varying_idx, fixed_idx] = find(dsq == mindsq);
Then it is the case that for each element in varying_idx, x(varying_idx(K)), y(varying_idx(K)) is the closest point to x(fixed_idx(K)), y(fixed_idx(K))
The reason why there can be multiple elements in varying_idx is that it is possible that there are two different points that are exactly as far as each other to their closest corresponding points in the fixed curve.
5 comentarios
Walter Roberson
el 28 de Feb. de 2020
All_residue = sum((all_varying_y - fixed_y).^2), 2);
[~, best_curve_idx)] = min(All_residue)
This assumes that the fixed_y is a row vector and that all_varying_y is a 2d array with any one curve being along the row.
This algorithm does not count the number of points that are "quite close" the way you asked. Instead it calculates sum of squared distance. For example if you had a curve in which the first three y were quite far away but the rest were nearly identical to the fixed curve, then the number that are nearly the same would be high, but the three points that are wildly different would result in quite an overall difference.
Más respuestas (0)
Ver también
Categorías
Más información sobre Smoothing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!