1
\$\begingroup\$

Using Matlab, I am trying to:

  • Get the overall difference equation relating to z[n] to x[n] and check if
  • z[n] = x[n] is a valid solution to the overall difference equation

I have two signals given by the differential equations:

  • z[n] + az[n−N] = y[n]
  • y[n] = x[n] + ax[n−N]

Where x[n] is an uncorrupted speech signal, which has been delayed by N samples and added back in with its amplitude decreased by a <1. Also, N = 1000, and the echo amplitude,a = 0.5.

What I have at this point:

% z[n] + az[n - N] = y[n]
% y[n] = x[n] + ax[n - N]

% Replacing:
% z[n] + az[n - N] = x[n] + a[n - N]
% z[n] = x[n] + a[n - N] - az[n - N]

syms z(n) % z[n] = dz/dn
syms x(n)

ode = diff(z,n) == ??

But I am stuck in how should I add the x[n] part.

How do I show these equations are equivalent?

As requested, I am adding more information about this overall question:

I am using a speech that was recorded with a sampling rate of 8192 Hz (I can hear the speech by typing sound(y,8192). The signal y[n], represented by the vector y, is of the form:

y[n] = x[n] + ax[n−N] (1)

where x[n] is the uncorrupted speech signal, which has been delayed by N samples and added back in with its amplitude decreased by a <1. This is a reasonable model for an echo resulting from the signal reflecting off of an absorbing surface like a wall.

For the problems in this exercise, I am using the value of the echo time, N= 1000, and the echo amplitude , a= 0.5.

My first task and also my question here was to remove the echo by linear filtering. Since the echo can be represented by a linear system of the form Eq. (1) I determined and plotted the impulse response of the echo system Eq. (1). I stored this impulse response in the vector he for 0≤n≤1000.

Now I need to consider an echo removal system described by the difference equation

z[n] +az[n−N] = y[n] (2)

where y[n] is the input and z[n] is the output which has the echo removed. I need to derive the overall difference equation relating z[n] to x[n] and check if z[n] =x[n] is a valid solution to the overall difference equation.

My whole code at this point is:

% Testing the input:
sound(y,8192)


    %% Part A:
    % create the impulse response
    M = 1; % MATLAB indexing offset
    N = 1000;
    h = zeros(1001,1); 
    h(M+0) = 1;
    h(M+1000) = 1;
    stem(h);
    he = h;

    %% Part B:
    % z[n] + az[n - N] = y[n]
    % y[n] = x[n] + ax[n - N]

    % Replacing:
    % z[n] + az[n - N] = x[n] + a[n - N]
    % z[n] = x[n] + a[n - N] - az[n - N]

    syms z(n) % z[n] = dz/dn
    syms x(n)

    ode = diff(z,n) == 
\$\endgroup\$
  • \$\begingroup\$ Sorry, but I read you text a few times and still cannot quite get what you are trying to do, could add more info and clarify a bit? Also, if you have x (the speech signal) are you calculating some y_1 and comparing that to something? Do you have some y_2 generated by some different signal of difference equation? Finally, could you post more of your code? \$\endgroup\$ – jDAQ Oct 4 '19 at 3:03
  • \$\begingroup\$ @jDAQ , just added more information. I hope that it explains better. \$\endgroup\$ – Fabio Soares Oct 4 '19 at 3:16
  • \$\begingroup\$ I suggest taking a step back in your explanation and keeping it on a fairly high abstraction. It's way to much information :) - Do a drawing of the signal path.. (1) Raw data > (2) Echo signal > (3) Echo removal > (4) Compare signals ? It's like reading a DSP book, way to many equations/noise just to make it look good. \$\endgroup\$ – Sorenp Oct 4 '19 at 4:14
1
\$\begingroup\$

Sure:

\$ z[n] + az[n−N] = y[n] \$

now lets take the above equation and substitute x[n]=z[n]

\$ x[n] + ax[n−N] = y[n] \$

which looks exactly like the other equation, so they are equivalent

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

It really isn't clear what you're asking here.

You have a signal y that represents x plus an echo:

  • y[n] = x[n] + ax[n-N]

You then process y through the following recursive filter in an attempt to remove the echo.

  • z[n] = y[n] - az[n-N]

The question is whether z[n] matches x[n] for all n.

You can rearrange the second equation to solve for y

  • y[n] = z[n] + az[n-N]

Since this has the exact same form as the first equation, then the answer to the question must be "yes".

So now you want to demonstrate this by doing the point-by-point calculation in Matlab. Just do the computation described by the first two equations and compare z[n] with x[n].

It might be worthwhile for you to work out a simple example by hand first, rather than jumping straight into Matlab. Generate a set of ten random integers to represent your signal x, and use an echo value (N) of, say 3. Once you understand all of the steps involved, writing the Matlab code should be straightforward.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.