1.完整的
2.部分的
1.完整的
clear
clc
close all
% 生成衰减曲线带有随机信号
fs = 50; % 采样率
t = 0:1/fs:100; % 时间向量,总时长为5秒
frequency=0.5;
signal = exp(-0.05* t).*sin(2*pi*frequency*t); % 衰减曲线带有随机信号
plot(t,signal)
signal=signal';
% 寻找衰减曲线的峰值
[peaks, peak_locations] = findpeaks(signal);
peak_locations= peak_locations/fs;
% 对峰值进行指数函数拟合
fit_model = fit(peak_locations, peaks, 'exp1');
% 获取拟合参数
fit_coefficients = coeffvalues(fit_model);
% 生成拟合曲线
fit_curve = fit_coefficients(1) * exp(fit_coefficients(2) * peak_locations);
% 绘制原始曲线和拟合曲线
figure;
plot(t, signal, 'b', 'LineWidth', 2, 'DisplayName', 'Original Signal');
hold on;
plot(peak_locations, peaks, 'ro', 'MarkerSize', 10, 'DisplayName', 'Peaks');
plot(peak_locations, fit_curve, 'g--', 'LineWidth', 2, 'DisplayName', 'Exponential Fit');
hold off;
xlabel('Time (seconds)');
ylabel('Amplitude');
title('Decaying Curve with Exponential Fit to Peaks');
legend('show');
zeta=-fit_coefficients(2)/(2*pi*frequency)
2.部分的
clear
clc
close all
% 生成衰减曲线带有随机信号
fs = 50; % 采样率
t = 0:1/fs:100; % 时间向量,总时长为5秒
frequency=0.5;
signal = exp(-0.05* t).*sin(2*pi*frequency*t); % 衰减曲线带有随机信号
plot(t,signal)
signal=signal';
% 寻找衰减曲线的峰值
[peaks, peak_locations] = findpeaks(signal);
peaks=peaks(10:40);
peak_locations=peak_locations(10:40);
peak_locations= peak_locations/fs;
fit_model = fit(peak_locations, peaks, 'exp1'); % 对峰值进行指数函数拟合
fit_coefficients = coeffvalues(fit_model); % 获取拟合参数
fit_curve = fit_coefficients(1) * exp(fit_coefficients(2) * peak_locations); % 生成拟合曲线
% 绘制原始曲线和拟合曲线
figure;
plot(t, signal, 'b', 'LineWidth', 2, 'DisplayName', 'Original Signal');
hold on;
plot(peak_locations, peaks, 'ro', 'MarkerSize', 10, 'DisplayName', 'Peaks');
plot(peak_locations, fit_curve, 'g--', 'LineWidth', 2, 'DisplayName', 'Exponential Fit');
hold off;
xlabel('Time (seconds)');
ylabel('Amplitude');
title('Decaying Curve with Exponential Fit to Peaks');
legend('show');
zeta=-fit_coefficients(2)/(2*pi*frequency)