A simple linear system is echo. It can be described by equation $$ y[n] = x[n]+ k\,x[n−d], $$ where $n$ represents sample index, $k$ represents an attenuation coefficient, and $d$ represents time lag.

How can I add echo to an input signal in MATLAB with convolution?

I'm new at MATLAB.


closed as off-topic by MBaz, Matt L., lennon310, Stanley Pawlukiewicz, Peter K. Dec 4 '18 at 15:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions requesting working code written to a specification are off-topic as they are unlikely to benefit anyone else. Instead, describe the problem you're solving and where you're stuck." – MBaz, Matt L., lennon310, Stanley Pawlukiewicz, Peter K.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Hint: what is the impulse response of a system that outputs $y[n]$ when the input is $x[n]$? $\endgroup$ – MBaz Nov 8 '18 at 23:43
  • $\begingroup$ I fixed the question. Input is just an audio signal not x[n]. So the question is how can i add echo with lag and attenuation factor based on that equation to some audio signal? I would really appreciate if someone can demonstrate me this in matlab. $\endgroup$ – ulica una Nov 8 '18 at 23:56
  • $\begingroup$ Other hint: Think about expressing this formula via matrix operations. What sort of matrix operation could give you $y[n]$? $\endgroup$ – A_A Nov 9 '18 at 9:06

The impulse response $h[n]$ can be obtained by inspection: $$ h[n] = \delta[n] + k \delta[n - d] $$

In MATLAB notation this would be:

h = [1, zeros(1,d-1), k];

The output is computed by:

y = conv(x, h);

Note that the time sample indices for the vector y will be as follows, assuming that both x and h are indexed where the first element corresponds to time $n=0$:

ny = 0:(length(x) + length(h) - 2);

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