finding several values close to the set point
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello!
I would like to calculate the period in a curve using the mean. However, my attempts to date have not been successful, and I think there is a simple way to do it.
I put random data - eventually I will have a lot of different data and this is to be the method for determining it.
I managed to find the closest value, but unfortunately 1, and I need a few of them to determine the curve's symmetry axis.
Edit: It doesn't search for peaks, because the data on which I work has a few of them on the main peaks, and filtration changes the shape of the plot very much.
Thank you for every advice.
A=[1.5 2.3 3.7 4.6 5.3 4.2 3.8 2.7 1.3 2.6 3.9 4.8 6.1 5.3 4.3 3.6 2.8 1.6 2.4 3.6 4.7 5.4 4.0 2.8 1.5 2.7 3.8 4.7];
A=A';
s = size(A);
t = 1:1:s(1);
plot (t,A)
a = mean(A);
Edit2:
In the attachment I add the real data I work on. From each cell I choose 1 column as X and 3 columns as Y in plot (X, Y).
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 3월 18일
The following code works by detecting the peak of each cycle and then calculate the average distance between each peak
A=[1.5 2.3 3.7 4.6 5.3 4.2 3.8 2.7 1.3 2.6 3.9 4.8 6.1 5.3 4.3 3.6 2.8 1.6 2.4 3.6 4.7 5.4 4.0 2.8 1.5 2.7 3.8 4.7];
A=A';
t = 1:1:size(A,1);
plot(t,A);
[~, index_peaks] = findpeaks(A);
t_peaks = t(index_peaks);
period = mean(diff(t_peaks));
댓글 수: 8
Ameer Hamza
2020년 3월 18일
Yes, that can be issue, but since you are taking the average of each interval so this difference is somewhat compensated.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!