简体   繁体   English

SymPy - 在反拉普拉斯变换时生成巨大的方程

[英]SymPy - Generates huge equation while inverse laplace transform

When I do a really simple inverse laplace transform with Sympy, I got a huge equation back. 当我用Sympy做一个非常简单的反拉普拉斯变换时,我得到了一个巨大的等式。

For example: 例如:

from sympy import *
s = symbols ('s')
t = symbols ('t', positive=True) # Just to remove the Heaviside(t) equations
k, m = symbols ('k m', const=True) 
A = Matrix([[0, 1], [-k/m, 0]])
I = eye(2) # Diagonalmatrix 
Fi = inverse_laplace_transform((s*I-A).inv(), s,  t)
print(pretty(simplify(Fi)))

Now a get an enormous huge equation from Fi . 现在,从Fi获得巨大的等式。 Why? 为什么? Is something wrong with inverse_laplace_transform() function from Sympy? Sympy的inverse_laplace_transform()函数有问题吗?

Inverse lapace transform is used to turn transfer functiuons into discrete form instead of time continuous. 逆空间变换用于将传递函数转换为离散形式而不是时间连续。

Instead of using inverse laplace transform, we can use this code instead, where h is the sample time. 我们可以使用此代码代替使用逆拉普拉变换,其中h是采样时间。 Image that we have a transfer function G(s), and you want to find the discrete equivalent model of G(s). 我们有传递函数G(s)的图像,并且您想要找到G(s)的离散等效模型。 Find the state space model of G(s) and then run this Octave/MATLAB code: 找到G(s)的状态空间模型,然后运行这个Octave / MATLAB代码:

% Compute sizes
a1 = size(A,2) + size(B,2) - size(A,1);
b1 = size(A,2);
a2 = size(A,2) + size(B,2) - size(B,1);
b2 = size(B,2);
% Compute square matrix
M = [A B; zeros(a1, b1)  zeros(a2, b2)];
M = expm(M*h);
 % Find the discrete matrecies
Ad = M(1:size(A,1), 1:size(A,2));
Bd = M(1:size(B,1), (size(A,2) + 1):(size(A,2) + size(B,2)));

Code source: https://github.com/DanielMartensson/Matavecontrol/blob/master/sourcecode/c2d.m 代码来源: https//github.com/DanielMartensson/Matavecontrol/blob/master/sourcecode/c2d.m

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

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