Matlab Code for Convolution is this right?

In summary, the unit response of a DT system with h[n] = (0.2(1.3)^n)u[n] is convolved with an input x[n] = sin(n*pi/2)u[n] to find the convolution. The input is multiplied by 1 when n >= 0 due to the definition of u[n]. It is important to note that the far end of the convolution sum may not be valid due to truncation, but this can be fixed by extending the signals.
  • #1
user101
207
0

Homework Statement



A DT system has the unit response h[n] = (0.2(1.3)^n)u[n]. You then input x[n] = sin(n*pi/2)u[n]. Find the convolution.

Homework Equations



None.

The Attempt at a Solution



>> n = 0:30;
>> h = 0.2*(1.3).^n;
>> x = sin(n*pi/2);
>> s = conv(h,x);

I left out u[n] because we know that u[n] = 1 whenever n >= 0 and 0 when n < 0. So, if I am correct, it is just multiplying the input by 1, if n >=0.

This should be right, just wanted to verify.
 
Last edited:
Physics news on Phys.org
  • #2
Looks good to me. Just remember that the far end of the convolution sum will not be valid because you are truncating it at 30. What the algorthm does is insert zeros at the front and back of the signals. This is all right on the low end because the signals are zero anyway below zero, but it will cause invalid results at the high end. This can be fixed by simply making the signals longer than you need.
 
  • #3
oh it didnt specify how far n should go, so i made it randoml from 0 to 30.
 

1. What is convolution in Matlab?

Convolution in Matlab is a mathematical operation that combines two functions to create a third function. It is widely used in signal processing, image processing, and other scientific fields.

2. How do I write a convolution code in Matlab?

To write a convolution code in Matlab, you first need to define the two functions that you want to convolve. Then, you can use the conv() function to perform the convolution and store the result in a new variable.

3. What is the syntax for the conv() function in Matlab?

The syntax for the conv() function in Matlab is as follows:
y = conv(x1, x2)
where x1 and x2 are the two functions to be convolved and y is the resulting function.

4. How do I check if my convolution code is correct in Matlab?

You can check the correctness of your convolution code in Matlab by comparing the output of your code with the expected result. You can also use the built-in conv() function to verify your code's output.

5. Can I use the conv() function for multidimensional arrays in Matlab?

Yes, the conv() function in Matlab can be used for multidimensional arrays. You can specify the dimension along which you want to perform the convolution using the optional parameter 'dim'.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
487
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
687
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
Back
Top