Addition of two plots (Coordinates)
3 views (last 30 days)
Show older comments
Amir Cawich on 26 Feb 2023
I am trying to draw a line between the peaks of a signal. I am using the following criterias: first locate all peaks that are higher than 150 using the MinPeakHeight function.However, there are regions where the peaks do not reach the 150 threshold. so I find the maximum peak within every interval of 25 using MInPeak Distance. Use the image for referal. The orange line is the one obtained using the threshold of 150 (produces a 1*9 matrix) and the yellow one is the one using a distance of 25 (produces a 1*13). Ideally i would like to combine both of these lines into one. But it becomes tricky having both the [pks,locs] like coordinates. Is there any way it can be done. I was also thinking of using a for loop and if statement to set boundaries but i am not sure this is the best way. I am not sure if it can be done. any ideas are welcome.
%%Using For loop i was trying something like this
if pks ==
dpb on 26 Feb 2023
You have to add the starting location of your subsection to the returned location if you subset the overall signal, The loop you show will only pass a point; you would need to set a width/length of the timeseries to do this way.
Try something like
locs=[locs1 locs2]; % combine the two sets into one
[locs,iloc]=unique(locs); % find the unique locations between the two
pks=pks(iloc); % get corresponding values
It would be beneficial and folks would probably chime in with far more creative solutions if you would attach the signal and define more specifically just what is the criteria by which a peak is/is not to be chosen. findpeaks is pretty flexible; more tweaking on its inputs might make things "more simpler" and, in particular, more repeatable from trace to trace.
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!