clear
clc
close all
% 生成衰减曲线带有随机信号
fs = 50; % 采样率
t = 0:1/fs:100; % 时间向量,总时长为5秒
signal = exp(-0.05* t).*sin(t); % 衰减曲线带有随机信号
plot(signal)
% 寻找衰减曲线的峰值
[peaks, peak_locations] = findpeaks(signal);
% 绘制原始曲线和峰值点
figure;
plot(t, signal);
hold on;
scatter(t(peak_locations), peaks, 'r', 'filled');
title('衰减曲线及其峰值点');
xlabel('时间(秒)');
ylabel('振幅');
legend('衰减曲线', '峰值点');
grid on;