using 'controlchart' and 'findpeaks'
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Fercho_Sala
el 13 de Abr. de 2021
Comentada: Star Strider
el 15 de Abr. de 2021
Hello everybody. I’m using the function “controlchart” to analyze something like the data in the picture, however I was wondering how to use the ‘’findpeaks’’ function to identify the peaks in the red circles and also the width of those peaks. Apparently the ‘’findpeaks’’ function doesn’t work properly in this case, it is possible to use both functions in one chart?. Thank you.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/581581/image.png)
1 comentario
Mathieu NOE
el 13 de Abr. de 2021
hello
we could probably better help you if you share a code and data
tx
Respuesta aceptada
Star Strider
el 13 de Abr. de 2021
That is going to be something of a challenge, however it is possible.
load parts
st = controlchart(runout,'charttype',{'xbar' 'r'});
Ax = gca; % Axis Handle
Kids = Ax.Children; % Axis ‘Children’
x = Kids(4).XData; % Choose Desired Variable, Get ‘XData’
y = Kids(4).YData; % Choose Desired Variable, Get ‘YData’
[pks,locs] = findpeaks(y, 'MinPeakProminence',0.5); % Peaks With Desired Characteristics
figure
plot(x, y)
hold on
plot(x(locs), y(locs), '^r')
hold off
grid
That should work, although it will likely be necessary to experiment with it to get the correct variable and the desired peak characteristics.
5 comentarios
Walter Roberson
el 14 de Abr. de 2021
plot((XDATA(locs,151), y(locs), '^r')
perhaps ?
Star Strider
el 14 de Abr. de 2021
@Walter Roberson — Thank you!
@Fernando Salamanca Guerrero — I cannot comment on how well my code works with your data. It may be necessary to change the code to work correctly with it, since it may have different characteristics from the characteristics of the data in the example code from the documentation that I used. I cannot help you with that because I do not have the data you are using, or your controlchart call. If you provide those, I can do more than guess as to what the correct approach would be.
Más respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!