david kang
david kang

Reputation: 11

How to find the first peak in matlab?

I want to find the first peak's value in Signal of matlab.

I used a bandpassFilter and got the signal that I uploaded.

Then, I need to find the first axis 'x' value of peak. How do I find it? I tried using the 'findpeaks' function, but I didn't know it exactly.

Upvotes: 0

Views: 2285

Answers (2)

Anil Bag
Anil Bag

Reputation: 1

l=length(A)
for i=1:l-1
    if((A(i)-A(i+1))<0)
       continue
    else
       maxm=A(i);
       J=i;
       break
    end
end

Example

A=[1 3 7 6 8 9 12 10 8]

maxm =

 7

J =

 3

Upvotes: 0

shamalaia
shamalaia

Reputation: 2347

I think that you can use max:

[M,I] = max(A)

where A is your signal, M the value of the maximum and I its position in the array.

Then with x(I) you can retrive its x-coordinate (where x is the vector with the values on your x axis).

Upvotes: 1

Related Questions