Find Diverging point of two arrays
이전 댓글 표시
Hi, I want to find the diverging point of two arrays. Please see the figure. In this figure the point may be around 44-48, where the arrays diverges fast. I am not able to do.

댓글 수: 1
dpb
2015년 10월 18일
Attach your data file for convenience; could generate some but why make the folks you're asking for help do more work than needed?
I gotta' run, but I think I'd probably start by fitting a trend line to each, remove that trend and compare residuals...
채택된 답변
추가 답변 (3개)
You can compute the difference between both lines and find the point of divergence when the difference exceeds some threshold.
threshold = 6; % sample threshold
find(abs(y1 - y2) > threshold, 1, 'first')
댓글 수: 5
chetan sharma
2015년 10월 20일
dpb
2015년 10월 20일
- Have you tried either of the above suggestions?
- Again suggest attaching a sample data file instead of expecting volunteers here to make up data on their own...
chetan sharma
2015년 10월 24일
Sorry about that but the browser here can't manage to download the link when it's not text (not your fault, it's Firefox). Can you attach a text file, perhaps after trimming its size some but retaining the key features? Apologize for the inconvenience but this seems an issue with how these links are interpreted that can't manage to actually download the file itself but copies it as text instead.
I do think, however, that for a characteristic curve such as you've shown, that finding that knee will be at least a first step in identifying the point of interest. I'll reiterate again, however ( :) ) that you've still not really provided a definition of what the definition of this point is except as some general description of "I'll know it when I see it", but that's not an implementable algorithm; there's needs to be some quantitative criterion/criteria.
ADDENDUM Or, I am contactable via the "Contributors" page; I can't promise when but I'd try to take a look at the data if you were to send it directly. I'd suggest attaching the files to your original question via "EDIT" rather as an Answer to the question you posed as it really isn't...
chetan sharma
2015년 10월 24일
I loaded your data and found that if y is the data of the higher curve, you can find the diverging point using
dp = find([1; diff(y)] < 0, 1, 'last');
The diverging point is determined by the upper curve only, the lower curves are pretty smooth. After diverging, the curve is monotonically increasing. The code finds the last point where the upper curve decreases.
댓글 수: 2
chetan sharma
2015년 11월 17일
diff takes the difference of adjacent elements. After diverging of curves, the upper curve is monotonically increasing, that is, diff is always > 0. The last position where diff is negative, i.e., where the curve decreases, is marked as the starting point. The 1; is used to shift this position by one to the right, because the divergence should start at the position of the lower number.
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!