How can I use the conv function to calculate convolution of two functions with different ranges?

11 views (last 30 days)
I want to calculate the convolution of two discrete functions with different ranges, let's say function x has range "[x_l, x_r]" and h has range "[h_l, h_r]".
I know that the length of the convolution should be (x_r + h_r - x_l - h_l + 1) and I can iterate over this range but how can I calculate it with the conv function. Considering the fact that conv calculates the convolution of two vectors (i.e. both x and h start at zero). I've thought about adding zero paddings to my x and h vectors but I'm not sure if that would work well with negative ranges.
  1 Comment
Cris LaPierre
Cris LaPierre on 1 Jan 2021
Edited: Cris LaPierre on 1 Jan 2021
From the Input Arguments section of conv documentation page:
  • The vectors u and v can be different lengths or data types.
Is there a specific error message you are getting? Can you provide code for us to replicate your problem?

Sign in to comment.

Answers (1)

Matt J
Matt J on 1 Jan 2021
Edited: Matt J on 1 Jan 2021
I've thought about adding zero paddings to my x and h vectors but I'm not sure if that would work well with negative ranges.
conv knows nothing about the "range" from which you are drawing the samples of x and h. There is really no reason not to pretend they are sampled on a common interval [0,T] when you convolve them. Any shift in either x or h will simply shift the convolution by a corresponding amount. .

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!