指数函数拟合

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)

  • 10
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值