Matlab中数据的衰减率

时间:2020-11-09 16:09:08

标签: matlab exponential

我想知道一些数据在初始峰值之后(此处大约为x=5)返回基线的速度有多快?

二次拟合看起来很正确(从matlab的图形选项中,如下所示)-但是我正在寻找对该曲线的精确量化,因此我假设'{{3} }'是一个非常简单的函数。

  1. 这个假设正确吗?
  2. 如果是,我为此查看了Wiki上的公式,并尝试着无耻地找到时间常数的解(但未成功)。有人可以帮我吗,或者这实际上不是一个小问题吗?

edit:我打算使用MathWorks的findpeaks()函数来找到峰,并使用'inverse'findpeaks()来找到曲线的最低点(如:-y)< / p>

decay rate

%approx data values of the curves below
y= [0   0.07    0.08    0.08    0.08    0.06    0.06    0.05    0.04    0.05    0.04    0.02    0.01    0.02    0.01    0.01    0.03    0.02    0.02    0.02    0.03    0.01    0.02    0.01    0.01    0.03    0.02    0.01    0.02    0.01];
x=1:numel(y);
plot(x,y);

enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

这是我一直在寻找的两个选项,也许有人可以详细说明/改进有关这些方法差异的答案-对我来说,这已经足够了,谢谢您的评论。在执行此步骤之前,使用问题示例中提供的数据,必须提取局部最大值和最小值,这可以使用findpeaks()

轻松完成。

方法1)需要Matlab [Source]的曲线工具箱

%Fit a Single-Term Exponential Model, copy from Mathworks documentation, all credits go there
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.1*randn(size(x));
f = fit(x,y,'exp1')
f = 
     General model Exp1:
     f(x) = a*exp(b*x)
     Coefficients (with 95% confidence bounds):
       a =       2.021  (1.89, 2.151)
       b =     -0.1812  (-0.2104, -0.152)
plot(f,x,y)

enter image description here


或方法2)需要Matlab [Source]

的优化工具箱
%copy from Mathworks documentation, all credits go there
rng default % for reproducibility
d = linspace(0,3);
y = exp(-1.3*d) + 0.05*randn(size(d));
fun = @(r)exp(-d*r)-y;
x0 = 4;
x = lsqnonlin(fun,x0)
plot(d,y,'ko',d,exp(-x*d),'b-')
legend('Data','Best fit')
xlabel('t')
ylabel('exp(-tx)')

enter image description here