Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Finding local max and min

jamie55jamie55 Posts: 1Member
Hey there,
first time poster but I have been working with matlab for nearly 2 years.

My problem is I have a given array called "stim".
When I plot as simply

plot(stim);

it looks like this: http://i703.photobucket.com/albums/ww40/jamie55_pics/matlab/fig.png

There is a brief period at the very beginning and the very end when stim hovers, with variety, around 0.

I need to find the points for all local max and min.

I tried using extrema, findpeaks with no success - I think there's too much fluctuations. If I zoom in to the peaks, you'll notice it:

http://i703.photobucket.com/albums/ww40/jamie55_pics/matlab/fig2.png

I tried using a for and if loop such as

M=[]; % array of max values

for i=2:length(stim)
if stim(i) > stim(i-1) && stim(i) > (stim(i+1)
M = [M i];
end
end

With no success. I keep getting unwanted values. Can anyone help?
This has been torturing me for a while.
Sign In or Register to comment.