Finding the exact end of decay period
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello All, I have some data such as the file attached. I want to know how I can find the exact end of the decay period so that I can later fit a linear line to my data. In my example, I want to know how to find the 10th data point automatically so that I can fit a linear line to data points from 1 to 10 not the whole data points. Basically I want MATLAB to find the exact end of the decay period. Because after the 10th point there is essentially no decay. Thanks everyone in advance.
댓글 수: 0
채택된 답변
Star Strider
2017년 5월 28일
One option is to use the diff function on the y values, then define the end as the first occurrence of a positive value. The problem with diff is that the output is one element shorter than the input.
You can do a similar approach with the gradient function. The advantage of using gradient is that the length of the output vector is the same as the input vector, making addressing easier. So, the first positive value of the derivative is the end of the data you want to use.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!