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:
peaks in curves

Subject: peaks in curves

From: Theo Kalfas

Date: 5 Mar, 2009 09:38:01

Message: 1 of 12

Hi,
I have a general question about curves.
if a have a curve(sine,cosine etc),is there a way to find the peaks of it or to display these peaks in my graph?
Thank you!!

Subject: peaks in curves

From: Thomas

Date: 5 Mar, 2009 09:56:01

Message: 2 of 12

"Theo Kalfas" <k_thodoros@yahoo.gr> wrote in message <goo6hp$kp8$1@fred.mathworks.com>...
> Hi,
> I have a general question about curves.
> if a have a curve(sine,cosine etc),is there a way to find the peaks of it or to display these peaks in my graph?
> Thank you!!

I'm not so sure what exactly you want to display or what peaks in a sinusoidal curve could exist. In general I use Wavelets or the respecive Wavelet decomposition to analyze and show peaks in curves, i.e. separating higher and lower frequencies. If you could get a little more specific I might help you more.

Regards

Thomas

Subject: peaks in curves

From: Theo Kalfas

Date: 5 Mar, 2009 10:22:02

Message: 3 of 12

> I'm not so sure what exactly you want to display or what peaks in a sinusoidal curve could exist. In general I use Wavelets or the respecive Wavelet decomposition to analyze and show peaks in curves, i.e. separating higher and lower frequencies. If you could get a little more specific I might help you more.
>
> Regards
>
> Thomas

Yes Thomas,this is what i want,to analyze and show peaks in curves.But i don't know if i can use Wavelet decomposition because(unfortunately)i'm not specific in matlab.If there is an other way to solve this kind of exercise then maybe you'll help me more.

Subject: peaks in curves

From: Thomas

Date: 5 Mar, 2009 10:47:02

Message: 4 of 12

"Theo Kalfas" <k_thodoros@yahoo.gr> wrote in message <goo949$shr$1@fred.mathworks.com>...
> > I'm not so sure what exactly you want to display or what peaks in a sinusoidal curve could exist. In general I use Wavelets or the respecive Wavelet decomposition to analyze and show peaks in curves, i.e. separating higher and lower frequencies. If you could get a little more specific I might help you more.
> >
> > Regards
> >
> > Thomas
>
> Yes Thomas,this is what i want,to analyze and show peaks in curves.But i don't know if i can use Wavelet decomposition because(unfortunately)i'm not specific in matlab.If there is an other way to solve this kind of exercise then maybe you'll help me more.

I'd like to help you but I fear I need more information about that? Are the curves you are talking about just given as data points or do you have an analytic function for them. I still do not really understand what kind of peaks you expect in a sinusoidal curve. Could you provide an example?

Regards

Thomas

Subject: peaks in curves

From: us

Date: 5 Mar, 2009 11:03:03

Message: 5 of 12

"Theo Kalfas"
> if a have a curve(sine,cosine etc),is there a way to find the peaks of it or to display these peaks in my graph...

one of the many(!) solutions
- given your rather fuzzy question...

     x=0:10:360;
     y=.8*sin(pi*x/180)+.2*(rand(size(x))-.5);
     ix=[false,y(1:end-2)<y(2:end-1)&y(2:end-1)>y(3:end),false];
     line(x,y);
     line(x(ix),y(ix),'marker','s','linestyle','none');

us

Subject: peaks in curves

From: Theo Kalfas

Date: 5 Mar, 2009 11:20:02

Message: 6 of 12

hmmm..You know i can't explain how is the curve exactly.Maybe if i give you the values then you understand.
I have a graph C(y axis)-V(x axis) where v=-4:0.05:0.5 and C has these values
1.25170E-11
1.26760E-11
1.28176E-11
1.29600E-11
1.31024E-11
1.32432E-11
1.33922E-11
1.34966E-11
1.36270E-11
1.37498E-11
1.38612E-11
1.40022E-11
1.41008E-11
1.42066E-11
1.43478E-11
1.44206E-11
1.45028E-11
1.46480E-11
1.47292E-11
1.48326E-11
1.49204E-11
1.50450E-11
1.51234E-11
1.52270E-11
1.52938E-11
1.53902E-11
1.54766E-11
1.55854E-11
1.56720E-11
1.57868E-11
1.58694E-11
1.59786E-11
1.60848E-11
1.61696E-11
1.62798E-11
1.63676E-11
1.64938E-11
1.65860E-11
1.66856E-11
1.67900E-11
1.68964E-11
1.69513E-11
1.70174E-11
1.71780E-11
1.73070E-11
1.74178E-11
1.75458E-11
1.76696E-11
1.77890E-11
1.79434E-11
1.80610E-11
1.82012E-11
1.83378E-11
1.84690E-11
1.86032E-11
1.87572E-11
1.89082E-11
1.90652E-11
1.92064E-11
1.93624E-11
1.94798E-11
1.96440E-11
1.97694E-11
1.99222E-11
2.00684E-11
2.01860E-11
2.03388E-11
2.04580E-11
2.05400E-11
2.06704E-11
2.07338E-11
2.08582E-11
2.09706E-11
2.10340E-11
2.10912E-11
2.11780E-11
2.12564E-11
2.12966E-11
2.13626E-11
2.14140E-11
2.14734E-11
2.15030E-11
2.15336E-11
2.14190E-11
2.11478E-11
2.07874E-11
2.03956E-11
2.01236E-11
1.99130E-11
1.98588E-11
1.98482E-11

And here is my question if there is a way to find the peaks in this graph.

Subject: peaks in curves

From: us

Date: 5 Mar, 2009 11:31:01

Message: 7 of 12

"Theo Kalfas"
> I have a graph C(y axis)-V(x axis) where v=-4:0.05:0.5 and C has these values
> And here is my question if there is a way to find the peaks in this graph...

instead of inconsiderately spamming this NG with 91 completely meaningless data points you should have looked at some of the replies, which tell you how to go about it...

us

Subject: peaks in curves

From: Thomas

Date: 5 Mar, 2009 12:04:03

Message: 8 of 12

"us " <us@neurol.unizh.ch> wrote in message <good5l$ksm$1@fred.mathworks.com>...
> "Theo Kalfas"
> > I have a graph C(y axis)-V(x axis) where v=-4:0.05:0.5 and C has these values
> > And here is my question if there is a way to find the peaks in this graph...
>
> instead of inconsiderately spamming this NG with 91 completely meaningless data points you should have looked at some of the replies, which tell you how to go about it...
>
> us

I concur... I still do not understand the problem. How do you define a peak? If it is a local maximum then us' solution will provide you them.

Subject: peaks in curves

From: ImageAnalyst

Date: 5 Mar, 2009 13:21:26

Message: 9 of 12

Thomas
Here's a nice peak and valley detector:
http://billauer.co.il/peakdet.html
It didn't take the endpoints into account (whether they also happened
to be a peak or valley) so I had to adapt it to also consider those.
But overall it works very nicely for 1D signals. It has some "delta"
that you can give to ignore small peaks. For example if you have the
profile of Mt. Everest you wouldn't want to find every little tiny
rock-sized increase in elevation or else you'd have millions of
peaks. You can tell it to ignore small local peaks due to noise.
Regards,
ImageAnalyst

Subject: peaks in curves

From: Thomas

Date: 5 Mar, 2009 13:41:01

Message: 10 of 12

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7dd59933-0d71-4f45-b2ca-1ff8e62ed5c3@d2g2000pra.googlegroups.com>...
> Thomas
> Here's a nice peak and valley detector:
> http://billauer.co.il/peakdet.html
> It didn't take the endpoints into account (whether they also happened
> to be a peak or valley) so I had to adapt it to also consider those.
> But overall it works very nicely for 1D signals. It has some "delta"
> that you can give to ignore small peaks. For example if you have the
> profile of Mt. Everest you wouldn't want to find every little tiny
> rock-sized increase in elevation or else you'd have millions of
> peaks. You can tell it to ignore small local peaks due to noise.
> Regards,
> ImageAnalyst

Thanks (though it was not me having the original problem).

Interestingly enough, I came about the exact same problem some time ago and solved it in a similar matter like you did, i.e. defining a threshold for a data set to determine whether a data point is a real local maxima more or less in the analytic sense or just due to some noise around it. But since the problem afterwards became obsolete in my case, I didn't finish the code completely.

Regards

Thomas

Subject: peaks in curves

From: Miroslav Balda

Date: 5 Mar, 2009 22:20:19

Message: 11 of 12

"Theo Kalfas" <k_thodoros@yahoo.gr> wrote in message <goo6hp$kp8$1@fred.mathworks.com>...
> Hi,
> I have a general question about curves.
> if a have a curve(sine,cosine etc),is there a way to find the peaks of it or to display these peaks in my graph?
> Thank you!!

Hi Theo
The solution is rather simply with my function extr (FEX Id. 10272):

v=-4:0.05:0.5 ;
C = [your vector];
L = extr(C);
plot(v,C, v(L{1}),C(L{1}),'^r', v(L{2}),C(L{2}),'vr')

It's all. All local maxima are C(L{1}), and local minima C(L{2}).
Best regards

Mira

Subject: peaks in curves

From: Theo Kalfas

Date: 6 Mar, 2009 09:08:01

Message: 12 of 12

Thank you all of you for your help.:-))

Tags for 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