Use MATLAB to compute the linear conv. and circular convolution
时间: 2023-12-14 07:35:44 浏览: 32
Sure, here's how you can compute linear and circular convolution using MATLAB:
Linear Convolution:
To compute linear convolution of two signals using MATLAB, you can use the `conv` function. Here's an example:
```matlab
x = [1 2 1];
h = [1 -1 2];
y = conv(x, h);
```
In this example, `x` and `h` are two input signals and `y` is the output signal obtained by convolving `x` and `h`. The `conv` function automatically performs linear convolution.
Circular Convolution:
To compute circular convolution of two signals using MATLAB, you can use the `cconv` function. Here's an example:
```matlab
x = [1 2 1];
h = [1 -1 2];
y = cconv(x, h, length(x));
```
In this example, `x` and `h` are two input signals and `y` is the output signal obtained by circularly convolving `x` and `h`. The `cconv` function requires the length of the output signal as the third argument, which is set to the length of `x` in this example.