且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

信号增强算法

更新时间:2023-02-27 09:10:29

我认为,您应该从一个非常简单的系统标识和连续的信号重建开始.另外,我建议您先在数学原型工具(例如Matlab(商业许可)或Octave(免费→ https://www.gnu.org/software/octave/download.html ).这些工具提供了轻松的信号处理能力,无论您使用哪种库,都无法像Pascal或Java那样提供编程语言.使用Matlab或Octave成功设计算法后,请考虑如何使用Pascal实施该算法.

In my opinion, you should start with a pretty simple system identification and consecutive signal reconstruction. Also, I would recommend to implement your algorithm first in a mathematical prototyping tool like Matlab (commerical license) or Octave (free → https://www.gnu.org/software/octave/download.html). These tools provide an ease of signal processing no programming language like Pascal or Java could ever offer, no matter what library you use. After you successfully designed your algorithm with Matlab or Octave, then think about how to implement it with Pascal.

让我们假设电子管的行为可以通过线性时不变系统(例如线性低通滤波器)来表征.这绝不是可以保证的,而是值得采用的方法(至少直到失败为止:)).对于非线性和/或时变系统,采用相同的方法非常困难,我想您将需要专业的帮助.

Lets assume the behaviour of the tube can be characterized by a linear time-invariant system (e.g. a linear lowpass filter). This is by no means guaranteed but a worthwhile approach (at least until it fails:) ). Following the same approach for non-linear and/or time-variant systems becomes pretty involved and you will need professional help to do this I would imagine.

如果我正确理解了您的描述,则可以访问电子管的输入和输出信号.如果我错了,并且您不知道输入信号,则可以先应用一些已知特征的校准信号,然后记录输出信号.知道输入和输出信号是以下方法的先决条件.如果没有这两个信号,您将无法估算电子管的脉冲响应h.在计算出h的近似值之后,我们可以设计一个称为ge的逆滤波器,并最终从输出信号重构输入.

If I understood your description correctly, you have access to both the input and output signals of the tube. If I am wrong and you don’t know the input signal, you might be able to apply some calibration signal first, whose characteristics you know, and record the output signal. Knowing input and output signals is a prerequisite for the following approach. Without both signals you can not approximate the impulse response h of the tube. After calculating an approximation of h, we can design an inverse filer called ge and eventually reconstruct the input from the output signal.

这是输入信号x [n]通过您的电子管的信号流,用h表示,产生输出信号y [n].取y [n]并应用ge描述的逆滤波操作,我们得到xr [n]

Here is the signal flow of a input signal x[n] passing your tube described by h producing the output signal y[n]. Taking y[n] and applying an inverse filtering operation described by ge we obtain xr[n]

x [n]→| h | →y [n]→| ge | →xr [n]

取长度为N的输入向量x和长度相同的y的对应向量. 现在,您将输出y表示为输入卷积矩阵X的卷积(有关实现,请参见下面的代码),其中包含系统未知的脉冲响应,即

Take an input vector x of length N and a corresponding vector of y of the same length. Now you express the output y as a convolution of an input convolution matrix X (see the code below for its implementation) with the unknown impulse response of your system, i.e.

y = X * h

向量和矩阵大小为y = N x 1,X = N x N和h = N x 1 您可以通过计算

with the vector and matrix sizes y = N x 1, X = N x N and h = N x 1 You can calculate a least-squares approximation of the impulse response he, by calculating

he = inv(X'* X)* X'* y

其中X'描述了X的转置和inv()的矩阵逆.他表示已确定的您的管的冲激响应的列向量,该列向量是通过 1-D反卷积获得的.您可以通过计算估算系统的输出来检查标识的工作情况,

where X' describes the transpose and inv() the matrix inverse of X. he represents a column vector of the identified impulse response of your tube which we obtained via a 1-D deconvolution. You can check how well the identification worked by calculating the output of your estimated system,

ye = X *他

并通过比较ye和y.现在,我们尝试从y和他重建x.重建的输入向量xr由

and by comparing ye and y. Now, we try to reconstruct x from y and he. The reconstructed input vector xr is calculated by

xr = Ge * y

其中Ge = inv(He),He是He的N x N卷积矩阵. 这是一些倍频程代码.将这两个函数复制到各自的专用文件中(reconstruct.m和getConvolutionMatrix.m),然后在Octave命令行中键入"reconstruct.m"以检查示例的输出.请注意,示例代码仅适用于奇数长度的向量(N为奇数).播放N个向量的大小.这可能有助于近似精度.

where Ge = inv(He) and He is the N x N convolution matrix of he. Here is some Octave code. Copy both functions in their own dedicated file (reconstruct.m and getConvolutionMatrix.m) and type "reconstruct.m" into the Octave command line to examine the outputs of the example. Please note the sample code works only for vector of odd length (N is odd). Play around with the size N of your vectors. This might help the approximation accuracy.

function [Ge] = reconstruct ()
    x = [1 2 3]';            # input signal
    # h = [1 3 2]';          # unknown impulse response
    y = [5 11 13]';          # output signal
    y = y + 0.001*randn(length(y),1)  # add noise to output signal 

    Xm = getConvolutionMatrix(x)
    Xps = inv(Xm'*Xm)*Xm';
    he = Xps * y
    He = getConvolutionMatrix(he);
    Ge = inv(He);
    # reconstructed impulse signal
    xr = Ge*y
endfunction

function [mH] = getConvolutionMatrix(h)
    h = h(:)';
    hlen = length(h);
    Nc = (hlen-1)/2;

    mH= zeros(hlen, hlen);
    hp = [zeros(1,Nc) h zeros(1,Nc)];

    for c=1:hlen
      for r=1:hlen
        mH(r,c) = hp(r+hlen-c);
      end
    end
endfunction