可以利用max函数获取最值的位置。如果是极值,可以通过微分来做。比如:% By lyqmath
% DLUT School of Mathematical Sciences
% BLOG:
http://blog.csdn.net/lyqmath% 有一组数据,Matlab怎样取得每个波峰波谷的数据
clc; close all; clear;
data=[105.03 99.18 84.965 72.445 68.994 77.265...
91.052 100.61 98.215 86.363 74.439 71.625...
80.061 92.18 97.823 91.483 80.241 73.616...
78.547 89.084 94.924 89.689 79.898 75.485...
81.544 89.485 90.578 83.712 77.401 80.18...
86.904 88.721 83.468 78.971 81.983 86.25...
85.224 80.901 80.808 84.488];
IndMin=find(diff(sign(diff(data)))>0)+1;
IndMax=find(diff(sign(diff(data)))<0)+1;
plot(1:length(data),data);
hold on;grid on;
plot(IndMin,data(IndMin),'r^')
plot(IndMax,data(IndMax),'k*')
legend('曲线','波谷点','波峰点')