Finding peak pressure value.
显示 更早的评论
Hello. Would you mind if you could assist me in my algorithm I did. I have to find every peak values generated randomly from walking patterns. For example I have subject one walk for certain amount of time, and I'm having sampling rate 100 samples per second. However the subject may take longer or less than the periodicity of sampling rate, however that is fine - this is not the issue. But my algorithm which is slop base, is not efficiently working to find every peak - Not the local maxima please. The txt file has numbers of one big vectors (say 1X3000 number) and reading row by row. Thank you so much in advance.

x=load('girl_1.txt');
tmax= length(x) ;
x4 = x(1:5:end);
t1_n = 1:5:tmax;
x1_n_ref=0;
k=0;
for i=1:length(t1_n)
if x4(i)>140
if x1_n_ref-x4(i)<0
x1_n_ref=x4(i);
alpha=1;
elseif alpha==1 && x1_n_ref-x4(i)>0
k=k+1;
peak(k)=x1_n_ref;
peak_time(k) = t1_n(i);
alpha=2;
end
else
x1_n_ref=0;
end
end
figure(1) hold on grid plot(t1_n, x4,'b');
采纳的回答
更多回答(1 个)
Star Strider
2016-2-23
1 个投票
In the documentation for the R2011a version of findpeaks function, it only takes one data argument, and the name-value pair arguments. (Also check to be sure if you have ‘sunspot.mat’.)
You have to use the documentation for the release you have. The online documentation is always for the latest release, and there can be significant version differences.
7 个评论
Ahmed Mostfa
2016-2-23
Ahmed Mostfa
2016-2-23
Star Strider
2016-2-23
I would use findpeaks with two outputs:
[pks,locs] = findpeaks(data)
to get the indices of the peaks as well as the values. You can use the ‘locs’ variable to give you the values of your independent variable that correspond to the peak values in ‘pks’.
If your algorithm produces better results for you than findpeaks, go with what works best for you.
Ahmed Mostfa
2016-2-23
Star Strider
2016-2-23
You will have to make the findpeaks call adaptive to your data.
Consider something like this:
D = load('Ahmed Mostfa girl2.txt','-ascii');
Dmax = max(D);
[pks,locs] = findpeaks(D, 'MinPeakHeight',Dmax/2, 'MinPeakDistance',20);
figure(1)
plot(D)
hold on
plot(locs, pks, '*r')
hold off
grid
This works on that particular data set. It only picks up peaks that are half the maximum peak. The MinPeakDistance would be set as a constant and would eliminate peaks created by sampling and other broadband noise. I don’t know what your other data are, so I cannot code any particular alternative adaptive method.
Ahmed Mostfa
2016-2-24
Star Strider
2016-2-25
My pleasure.
If my Answer solved your problem, I would have asked you to Accept it.
类别
在 帮助中心 和 File Exchange 中查找有关 Spectral Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!