Causal system giving a non-causal output?

83 Views Asked by At

I have just written a Python code ploting DFT's using the convolution product:

$$y[t] = u[k] * h[k] = \sum_{k=-\infty}^{+\infty} u[k] h[t-k]$$

I'll take a high resolution so the graph is more precise. Here is a simple example,for $h(t) = \delta(t)$ and $u(t) = \sin(t)\nu(t)$:

Matplotlib

So far, so good. The causal system gives a causal answer.

Yet, for $h(t) = \nu(t) - \nu(t-6)$, I obtain this graph:

Matplotlib 2

The causal signal gives a non-causal answer. Indeed, $y(t)$ is not equal to $0$ for $t<0$ How is it possible ? Maybe is it a mistake from my code ?

1

There are 1 best solutions below

2
On

As cleverly suggested by @AndreasLenz, I wrote $k-t$ instead of $t-k$ in the convolution formula:

new_h_expression = ""
        for char in h_expression:
            if char == 't':
                new_h_expression = new_h_expression + "k-" + str(t) # here!
            else:
                new_h_expression = new_h_expression + char

It is now corrected and the new graph is causal as expected:

Matplotlib

Thanks a lot !