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??
댓글 수: 2
채택된 답변
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!