How can i create my own convolution function?

16 views (last 30 days)
his is what the professor is asking:
Write a function called MyConv that performs the convolution of two input vectors and returns the result. The formula for the convolution at position n looks like this:
w(n) =Σx(k)y(n − k)
You can use an inner loop to compute this sum of products, and then use an outer loop to vary n from the first position to the last. For example, if length(x) = p and length(y) = q, then there are p + q - 1 positions where there is an overlap between the two arrays. This means that the loop should go from 1 to p + q – 1. 1. Solve the problem by using a nested loop and suggested above. 2. Solve the problem by reversing one of the functions using the reverse function, and then using zero padding at the ends of the vectors, multiplying them together and summing them. Then change the zero padding to create a different shift and repeat this sequence (multiply and sum) to get the next value and so on. The two methods should produce identical results.
I HAVE DONE THE INNER LOOP METHOD. I CAN'T FOR THE LIFE OF ME FIGURE OUT PART 2.

Answers (0)

Community Treasure Hunt

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

Start Hunting!