Somebody could help me. I use Matlab program.
Suppose, I have vector A,
A = [0 0 1 2 3 5 0 0 0 0 0 2 3 6 7 0 0 0 0 1 1 2 3 4 1]
I
I assume you are seeking local maximum values - that is, values that are greater than those around them.
My solution would be this:
Loc = find(diff(A)(2:end)<0 & diff(A)(1:(end-1))>0)+1;
Val = A(Loc);
Loc will contain the positions of the local maxima, and Val will contain the values at those local maxima. Note that it will NOT find maxima at the edges, as written. If you want to detect those as well, you must modify it slightly:
Loc = find([A(1)>A(2),(diff(A)(2:end)<0 & diff(A)(1:(end-1))>0),A(end)>A(end-1)]);
Val = A(Loc);