Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Calculating peaks of sine wave

Subject: Calculating peaks of sine wave

From: atul mahajan

Date: 11 Nov, 2009 19:31:03

Message: 1 of 3

Hi

I have a matrix of size about 1X400000. It stores a sinusoidal signal with increasing amplitude.

For example, 1st peak is at 2V, 2nd peak at 2.5V, 3rd peak at 3V and so on until it saturates at some particular level. i want to calculate the time at which each peak occurs. can some one please suggest me the way to do it in matlab.

thanks in advance

atul

Subject: Calculating peaks of sine wave

From: James Tursa

Date: 11 Nov, 2009 20:25:21

Message: 2 of 3

"atul mahajan" <atul_techno@yahoo.com> wrote in message <hdf3dn$2mv$1@fred.mathworks.com>...
> Hi
>
> I have a matrix of size about 1X400000. It stores a sinusoidal signal with increasing amplitude.
>
> For example, 1st peak is at 2V, 2nd peak at 2.5V, 3rd peak at 3V and so on until it saturates at some particular level. i want to calculate the time at which each peak occurs. can some one please suggest me the way to do it in matlab.
>
> thanks in advance
>
> atul

Looks like there are some functions in the signal processing toolbox that will do this, e.g. findpeaks. Or, if you need to write your own simple function (and the data is not noisy) you could try something like this:

a = 0:.01:100;
b = sin(a).*a;
d = b(2:end)-b(1:(end-1));
s = sign(d);
t = s(2:end)-s(1:(end-1));
f = find(t);
plot(a,b,'-',a(f),b(f),'o')

The f variable contains the indexes for the location of the peaks. If the data is noisy then you have more work to do (smooth the data first, etc.).

James Tursa

Subject: Calculating peaks of sine wave

From: James Tursa

Date: 11 Nov, 2009 23:33:18

Message: 3 of 3

"atul mahajan" <atul_techno@yahoo.com> wrote in message <hdf3dn$2mv$1@fred.mathworks.com>...
> Hi
>
> I have a matrix of size about 1X400000. It stores a sinusoidal signal with increasing amplitude.
>
> For example, 1st peak is at 2V, 2nd peak at 2.5V, 3rd peak at 3V and so on until it saturates at some particular level. i want to calculate the time at which each peak occurs. can some one please suggest me the way to do it in matlab.
>
> thanks in advance
>
> atul

Also, you might check this FEX submission out:

http://www.mathworks.com/matlabcentral/fileexchange/25500-peakfinder

James Tursa

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us