- #1
ecastro
- 254
- 8
Considering two functions of ##t##, ##f\left(t\right) = e^{3t}## and ##g\left(t\right) = e^{7t}##, which are to be convolved analytically will result to ##f\left(t\right) \ast g\left(t\right) = \frac{1}{4}\left(e^{7t} - e^{3t}\right)##.
According to a Convolution Theorem, the convolution of two functions can be solved by the use of Fourier Transforms. The theorem states that,
##f\left(t\right) \ast g\left(t\right) = \mathcal{F}^{-1} \left\{\mathcal{F}\left[f\left(t\right)\right] \cdot \mathcal{F}\left[g\left(t\right)\right]\right\}##.
Thus, if I were to transform ##f\left(t\right)## and ##g\left(t\right)##, multiply them per component and take the inverse transform, I should get the same function that was solved analytically. I tried doing this in MatLab, but they're two totally different functions. Also, I tried using MatLab's built-in function for convolution ##\texttt{conv}##, but the resulting size of the matrix is almost twice as large, and the graph is off by several units (although the graph from the Fourier Transform approach and the latter share the same shape). Did I miss anything on why this is so?
Here is my code:
The variable ##\texttt{t2}## is for the drawing of the plot of the Fourier Transform approach and the ##\texttt{conv}## approach in the same graph.
According to a Convolution Theorem, the convolution of two functions can be solved by the use of Fourier Transforms. The theorem states that,
##f\left(t\right) \ast g\left(t\right) = \mathcal{F}^{-1} \left\{\mathcal{F}\left[f\left(t\right)\right] \cdot \mathcal{F}\left[g\left(t\right)\right]\right\}##.
Thus, if I were to transform ##f\left(t\right)## and ##g\left(t\right)##, multiply them per component and take the inverse transform, I should get the same function that was solved analytically. I tried doing this in MatLab, but they're two totally different functions. Also, I tried using MatLab's built-in function for convolution ##\texttt{conv}##, but the resulting size of the matrix is almost twice as large, and the graph is off by several units (although the graph from the Fourier Transform approach and the latter share the same shape). Did I miss anything on why this is so?
Here is my code:
Code:
clear; clc;
t = 0:0.01:1;
y = (1/4).*(exp(7.*t) - exp(3.*t));
f = exp(3.*t); g = exp(7.*t);
F = fft(f); G = fft(g);
FG = ifft(F.*G); FG2 = conv(f, g);
t2 = 0:0.005:1;
The variable ##\texttt{t2}## is for the drawing of the plot of the Fourier Transform approach and the ##\texttt{conv}## approach in the same graph.