findpeaks 函数可以直接返回极大值点的索引的,利用该索引去找出横坐标即可
wn=3.4338;zeta=0.14037;wd=wn*sqrt(1-zeta^2);X=0.4550;
t=0:0.01:20;
y=X.*exp(-zeta.*wn.*t).*sin(wd.*t);
[pks,locs] = findpeaks(y);
t(locs)
plot(t,y,'k-',t(locs), y(locs),'ro')
[attach]115925[/attach]
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!