Finding Maximum Peaks in a Program Plot

AI Thread Summary
The discussion revolves around the challenge of identifying maximum peaks in a time versus current graph. The user initially set a threshold of 0.05 to filter values but struggles with defining peaks due to fluctuations and varying peak heights. Suggestions include tracking maximum current values during voltage transitions and potentially using curve fitting for better accuracy. The user also seeks advice on correlating transition data with the original time array but encounters matrix dimension errors when attempting to find corresponding values. Overall, the conversation highlights the complexities of peak detection in noisy data and the need for effective data handling techniques.
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
Can you sort the values on tcurrent?
 
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: 393
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?
 
Thread 'Have I solved this structural engineering equation correctly?'
Hi all, I have a structural engineering book from 1979. I am trying to follow it as best as I can. I have come to a formula that calculates the rotations in radians at the rigid joint that requires an iterative procedure. This equation comes in the form of: $$ x_i = \frac {Q_ih_i + Q_{i+1}h_{i+1}}{4K} + \frac {C}{K}x_{i-1} + \frac {C}{K}x_{i+1} $$ Where: ## Q ## is the horizontal storey shear ## h ## is the storey height ## K = (6G_i + C_i + C_{i+1}) ## ## G = \frac {I_g}{h} ## ## C...

Similar threads

Back
Top