how to find every minimum and maximum values of a graph?

117 views (last 30 days)
I did a graph on Matlab and I'm trying to locate every Minimum and maximum on the graph. This is the graph code What is the code to find every minimum and maximum values in this graph?
x = linspace (-6,6);
y = (x+6) .* (x+4) .* (x+2) .* (x) .* (x-2) .* (x-4) .* (x-6) ;

Answers (1)

Matt J
Matt J on 26 Sep 2015
ymax=max(y);
xmax=find(y==ymax);
xmin=find(y==min(y));

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!