MATLAB: Finding minima

finding minima

I have a data file with few valleys (minima). is there a way to find all the x coordinates corresponding to each minimum y value?

Best Answer

If you want fancy, take Walter's advice and search FEx. If you want quick and dirty:
x = 1:50;
y = sin(5*x);
idx = [false, y(3:end)>y(2:end-1) & y(2:end-1)<y(1:end-2), false];
xmin = x(idx)
plot(x,y,'o-',xmin,y(idx),'rx')