title: find peak values in matlab
body: <p>suppose that we are determine peaks  in  vector  as follow:
  we have real values one dimensional vector  with length  m,or
  x(1),x(2),.....x(m)
  if   x(1)>x(2)  then  clearly for first point peak(1)=x(1);else  we are then comparing  x(3)  to x(2),if x(3)
  
  <pre><code>[ indexes,peaks]=function(x,m);
  c=[];
  b=[];
  if  x(1)&gt;x(2) 
      peaks(1)=x(1);
  else
  
   for i=2:m-1
       if x(i+1)&lt; x(i) &amp; x(i)&gt;x(i-1)
           peak(i)=x(i);
       end;
   end
  end
  end
  </code></pre>
  
  <p>peaks   are determined    also using following picture:
  <img src="https://i.stack.imgur.com/23OZn.jpg" alt="enter image description here"></p>
  
  <p>sorry for the second picture,maybe it is not  triangle,just   A and C are on straight line,but here peak is B,so  i can't continue  my code for  writing algorithm to find peak values  in my vector.please help me to  continue it</p>
  
  <h1>updated.numercial example given</h1>
  
  <p>x=[2 1 3 5 4 7 6 8 9]
  here because  first point is more then second,so it means that  peak(1)=2,then we are comparing 1 to  3,because 3 is more then 1,we now want to compare 5 to 3,it is also  more,compare 5 to 4,because 5 is more then 4,then it means that peak(2)=5,,so if we continue next peak is 7,and final peak would be  9
  in case of first element is less then second,then we are comparing  second element to third one,if  second is more then  third and first  elements at the same time,then peak is second,and so on</p>