Finding Maximum Peaks in a Program Plot

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 4K views
rai_88
Messages
4
Reaction score
0
Hi there. I am having some problems trying to find maximum peaks in my program. I plotted out my time vs. current graph. I need to find the maximum peaks. So i started off by setting a threshold of 0.05. After finding values which has a threshold of above 0.05, i plotted them.

>>ind=current>0.05;
>>ttime=time(ind);
>>tcurrent=current(ind);
>>plot(ttime,tcurrent,'.');axis([6 6.025 0.05 0.3]);

Now how can i find the all the maximum peaks? Could anyone help me out here? I really appreciate your help. Thank you.
 
Physics news on Phys.org
Thank you for your reply. Sort the values? But i have multiple peaks. Attached is the figure for my current vs. voltage plot. So for every peak, i need to find the maximum value. After finding all the maximum values for every peak, i need to plot just the maximum values. Any advice?
 

Attachments

  • currentVsvoltage.jpg
    currentVsvoltage.jpg
    15.8 KB · Views: 420
Ah. I see the problem. The peaks are somewhat ill-defined, so there may be some curve fitting involved, and they're not exactly evenly spaced, so it's a bit nasty.

You could "walk" though the voltage values and keep track of maximum current value. Each time the current value drops below 0.2 you declare the last maximum a "peak", and start looking for another peak when the values begin to exceed 0.2 again. This will find the peaks, if somewhat crudely. Someone with a lot of time on there hands might engineer a curve fit for the neighborhood of each peak.
 
Well, that is a good suggestion. But i just went through all the peaks. Some of the peaks are below 0.2. So it is hard to set a threshold because the fluctuation is large between the peaks. I was wondering, what if for every transition that happens, i find the start and end of the transition. Then i compute the average current and just use that as the max peak. So to say, since i can't find the max peak, i just find the average peak. Currently, i manage to find the start and end time for every transition. I stored the values into array 'data'. But how can i use the value in data to find back the time in the original array 'time' so i can find the corresponding current value? It gives me the following error:

>> find(time==data(:,1));
? Error using ==> eq
Matrix dimensions must agree.

I cannot find the values when the number of elements for both matrixes is not the same?
 
Hmm. Looking at your scatter plot I didn't notice any peaks below 0.2.

What prevents you from pulling out and storing all the information (voltage, current, time) as you find the transitions?