Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1494
Number of posts: 2174

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Finding local max and min Posted by jamie55 on 30 Nov 2012 at 12:15 PM
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.
Attachment: fig2.png (6128 Bytes | downloaded 23 times)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.