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 次查看(过去 30 天)
显示 更早的评论
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??
采纳的回答
Walter Roberson
2020-2-27
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 个评论
Walter Roberson
2020-2-28
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!