MATLAB Answers

Finding Peak Edges from Array of 116 Curves

35 views (last 30 days)
Christopher Gordon
Christopher Gordon on 21 Jan 2021
Commented: Mathieu NOE on 28 Jan 2021 at 7:52
Hello! I want to first say I'm incredibly appreciative of this community and its response to questions. People like me very much appreciate it. Here is my situation:
I have an array of 116 curves:
Each cuve is a single peak:
What I'm trying to do is find the edges of the peaks and the position of those edges:
I have successfully used findpeaks() to find the position, location, and peak width of each of the 116 curves/peaks, but the peak width is limited to either the bandwidth at halfheight or halfprominance. I was wondering if anyone could help me with an approach that could help me find the peak edges and what index/pixel it occurs at. I would greatly appreciate it.

  0 Comments

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 22 Jan 2021
hello
I suggest to use the attached crossing function , with the y threshold corresponding the y value of the black line in your picture.
the function allows you to get the positive slope (left crossing) point and the negative slope (right crossing) point
hope it helps

  13 Comments

Christopher Gordon
Christopher Gordon on 27 Jan 2021
How would you set that kind of argument up as a for argument? I would like to have it as its own separate step in the function in case I want to move it around in the program.
Christopher Gordon
Christopher Gordon on 27 Jan 2021 at 20:40
Again, thank you so much for all the help and sorry I keep asking so much. I went through the MatLAB crash course, but they only ever do simple examples and I have trouble expanding them, perhaps using other techniques that I haven't learned yet.
Up until now I have three matricies for this step:
t0_pos (116 x 1) that has the left side of each peak
t0_neg (116 x 1) that has the right side of each peak
AllCurves (1024 x 116) that has each curve
I would like the loop (or if there's a better way I'm open) to go through each curve and set that sections range of t0_pos to t0_neg equal to 0.
Mathieu NOE
Mathieu NOE on 28 Jan 2021 at 7:52
hello Cristopher
no problem, I like to work on (interesting) posts !
One problem I figured out this night is that the t0_pos and t0_neg values are obtained by linear interpolation for maximal precision; this is good , but on the other side , these "new" time values do not belong to the original time vector , and they are different for eah individual curve;
so at the end, I cannot create a common time axis for all curves , unless I do not merge the crossing points coordinates into the original x and y datas
IMO, we should step back to what was the first implementation and add some steps :
  • do a for loop in the main code
  • do the crossing stuff on one y vector at a time
  • merge the x and y original datas with the crossing points coordinates (and sort x in ascending order to avoid zig zags in plot)
  • put the y section between x = t0_pos to t0_neg equal to 0
  • repeat for all curves
  • this implies each curve a a specific x vector
  • plot with hold on

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by