简体   繁体   English

如何在Matlab中对离散输入信号执行数值Laplace和拉普拉斯逆变换?

[英]How to perform a numerical Laplace and inverse Laplace transforms in Matlab for a discrete input signal?

I want to evaluate the Laplace transform of a discrete stochastic signal I sample from a communication device. 我想评估从通信设备采样的离散随机信号的拉普拉斯变换。

As a simple test case I am trying to use the ilaplace to get the original signal, but I am not sure if my approach is plausible. 作为一个简单的测试用例,我尝试使用ilaplace来获取原始信号,但是我不确定我的方法是否合理。

x = sym('x','real');
y = sym('y','real');
t=linspace(0,1000,1000);
f=sin(t);
s = x+i*y;               
F_s=sum(f.*exp(-s*t));   
ilaplace(F_s)

The above might seem silly, though in my real problem I am trying to estimate the medium Green's function which is of the form ilaplace(2*F_s/(-s*F_s +f(0))) . 上面的内容似乎很愚蠢,尽管在我真正的问题中,我试图估算中等格林函数 ,其形式为ilaplace(2*F_s/(-s*F_s +f(0)))

I have also tried to use a signal symbolic variable s and it gives me a train of deltas which I am not sure it's correct and what is the error estimation. 我也尝试过使用信号符号变量s ,它给了我一系列的增量,我不确定它是否正确以及什么是误差估计。

syms s;                                
F_s = symfun(sum(sin(t).*exp(-s*t)), s);
ilaplace(F_s)

Try increasing the number of elements in t to more accurately sample the sine function, or smoothing the signal before calculations. 尝试增加t的元素数量,以更准确地采样正弦函数,或者在计算之前对信号进行平滑处理。 Another problem you face is that the inverse Laplace transform expects a function to be defined for s>0 , ie up to infinity. 您面临的另一个问题是,拉普拉斯逆变换要求为s>0定义函数,即最大无穷大。 You truncate your signal at t=1000 , thus the Laplace transform is not going to infinity either. 您在t=1000处截断信号,因此Laplace变换也不会达到无穷大。

Judging the documentation of ilaplace it tries to transform each individual term in your array F_s . ilaplace文档来看,它尝试转换数组F_s 每个单独术语 This has a sum of a thousand entries of some constant times some exponential of the form exp(-s*t) , whose inverse transform is a delta pulse, see this Wikipedia page, second entry of the table . 它具有一千个常数项的总和,常数形式为exp(-s*t)指数形式,其逆变换为增量脉冲,请参阅此Wikipedia页面,该表的第二项 Hence, your inverse transform of F_s is a series of a thousand delta pulses, which will presumably be exactly the thousand input points you generated with your sin(t) , up to some numerical error which emerged in the forward and backward Laplace transform. 因此,您对F_s的逆变换是一系列的一千个增量脉冲,可能恰好是您用sin(t)生成的一千个输入点,直到在向前和向后拉普拉斯变换中出现的一些数字误差为止。

Finally: MATLAB expects, as stated in the documentation, a single symbolic variable s . 最后:如文档所述,MATLAB期望单个符号变量s You made s consist of two symbolic variables. 您使s包含两个符号变量。 Whilst mathematically correct, MATLAB only takes the first symbolic variable to be the transform variable, thus you get an answer with delta pulses multiplied by some exp(1i*y) function. 在数学上正确的同时,MATLAB仅将第一个符号变量用作变换变量,因此您将获得增量脉冲与某个exp(1i*y)函数相乘的答案。 Using the following code, you at least get rid of that problem (but obviously keep the summation of delta pulses): 使用以下代码,您至少可以摆脱该问题(但显然要保持增量脉冲的总和):

t=linspace(0,1000,1000);
f=sin(t);
syms s
F_s=sum(f.*exp(-s*t));   
ilaplace(F_s)

Ok so that's the way I used matlab to do laplace transform for a discrete signal and recovered it back using ilaplace for validation purposes: 好的,这就是我使用matlab对离散信号进行laplace变换并使用ilaplace将其恢复回以进行验证的方式:

t=linspace(0,10,500);
f=exp(-t/0.2);   
syms s;                                
F_s = sum(f.*exp(-s*t));
f_t = (ilaplace(F_s)); 
F_t = (int(f_t));

y=subs(F_t,t);
Ft_recovered = diff(double(y));


subplot(2,2,1)
plot(t,f)
title('numerical input exp(-t/0.2)')


subplot(2,2,2)
ezplot(F_s)
title('numerical laplace')


subplot(2,2,3)
plot(t(1:end-1), Ft_recovered)
title('recovered signal')


subplot(2,2,4)
syms x;
fx = symfun(exp(-x/0.2),x);
ezplot(laplace(fx))
title('symbolic laplace transform')

The big difficulty here is to make matlab to evaluate the sum of the dirac delta train, so I did this trick: integrated the expression to convert it to train of heaviside functions, evaluate it and then plot the derivative: 这里最大的困难是使matlab评估狄拉克三角洲列车的总和,所以我做了这个技巧:集成表达式以将其转换为重载函数的列车,对其进行评估,然后绘制导数:

F_t = (int(f_t));
y=subs(F_t,t);
Ft_recovered = diff(double(y));

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM