antonpuz
antonpuz

Reputation: 3316

solving convolution for symbols and function in matlab

i want to solve a convolution in matlab for two heaviside functions, the problem is that the matlab wont let me do this and pops an error saying:

??? Undefined function or method 'conv2' for input arguments of type 'sym'.

this is what i try to do:

syms x;
conv(heaviside(-1-x), heaviside(x+3))

i guess i can make a vector with the values that x can have and conv it using the vector but i dont want to predefine the range so i want to keep it a symbol.

any suggestions?

Upvotes: 1

Views: 7724

Answers (1)

Danil Asotsky
Danil Asotsky

Reputation: 1241

You can compute convolution directly from definition (http://en.wikipedia.org/wiki/Convolution), e.g. calculate integral:

syms x t  
symb_conv = int(heaviside(-1-(t-x)) * heaviside(x+3), x, -inf, inf)

Edit:

Really, it seems you convolution will be always infinity under these conditions.

Plots for original functions will be following:

ezplot(heaviside(-1-x), [-10 10])
ezplot(heaviside(x+3), [-10 10])

heaviside(-x-1) heaviside(x+3)

We need to reflect one of function to receive convolution. Let it will be second function:

enter image description here

If we compare first and last plot we can see that these two functions has infinite non-zero intersection for x<-3. It is means that convolution for t=0 will be infinity.

If we try to shift last plot in any direction that we also will have infinite non-zero intersection for x<(-3-t). Therefore, final convolution function will be infinity for any t.

Upvotes: 3

Related Questions