Hi,
I need to find the peak value of each force for the plotted graph and locate it in the graph.
I already use findpeaks but there is no answer and no error informed.
I'm not sure the flow and how to apply the findpeaks command.
Thank you in advance!
X=xlsread('Filtered JCF PHASE 1.xlsx',4,'Z5:AC55');
Y=xlsread('JCF PHASE 1_5UP.xlsx',4,'AN5:AP55');
Z=xlsread('JCF PHASE 1_5DW.xlsx',4,'AN5:AP55');
x1 = X(:,1); %the percentage
y1= X(:,2); %the force value 1
y2= Y(:,1); %the force value 2
y3= Z(:,1); %the force value 3
[pks,locs] = findpeaks (y1,x1);
findpeaks (y1, x1);
subplot(3,1,1);
plot(x1,y1,'r',x1,y2,'g',x1,y3,'b','Linewidth',3);
title('JCF HIP X');
xlhand = get(gca,'xlabel');
set(xlhand,'string','Percentage of stance phase (%)','fontsize',10)
ylhand = get(gca,'ylabel');
set(ylhand,'string',{'JCF (N)'},'fontsize',10);

 採用された回答

Tommy
Tommy 2020 年 6 月 5 日

0 投票

According to the findpeaks() documentation:
"A local peak is a data sample that is either larger than its two neighboring samples or is equal to Inf. Non-Inf signal endpoints are excluded."
and
"If there are no local maxima, then pks is empty."
None of your plots have local maxima. They do each have a maximum value, but these values are all endpoints.
How about just using max()?
[pk_1, loc_1] = max(y1);

6 件のコメント

arifahazwani AY
arifahazwani AY 2020 年 6 月 6 日
Thank you for your response.
I want to mark the peak of the curve, and record the value.
The negative and postive sign indicate the position. So, I think I can't use the max as the maximum value is at the end of the curve.
Is there any solution?
Thank you again.
Tommy
Tommy 2020 年 6 月 6 日
If you mean you'd like to find local minima in each plot, flip your data upside down while calling findpeaks():
[pk_1,loc_1] = findpeaks(-y1,x1);
arifahazwani AY
arifahazwani AY 2020 年 6 月 6 日
Thank you.
It's work.! But, how can I plot the value on the graph?
I try with single graph with the code below.
I got the value, but I need to mark on the graph.
Can you please share the script. thank you very much.
X=xlsread('Filtered JCF PHASE 1.xlsx',4,'Z5:AC55');
x1 = X(:,1);
y1= X(:,2);
[pks,locs] = findpeaks(-y1, x1);
figure
plot(x1,y1);
axis tight
hold on
plot(locs, pks, 'r*')
hold off
Tommy
Tommy 2020 年 6 月 6 日
編集済み: Tommy 2020 年 6 月 11 日
Remember that findpeaks() analyzed your data upside-down, so the peak(s) it returns should be flipped.
plot(locs, -pks, 'r*')
arifahazwani AY
arifahazwani AY 2020 年 6 月 11 日
Noted. thank youu.
Tommy
Tommy 2020 年 6 月 11 日
Happy to help!

サインインしてコメントする。

その他の回答 (0 件)

タグ

質問済み:

2020 年 6 月 5 日

コメント済み:

2020 年 6 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by