I convolved a square wave with a Gaussian wave using linear convolution. Can I get the original square wave back by deconvolving my output with the Gaussian function?
I took the FFT of both signals, divided and then took the IFFT to get back the square wave. The output I got looked like random noise. I thought this might be due to the fact that I am doing a division and some denominator values might be very low, hence causing this error. I tried to set up a threshold and obtained the result depicted below.
How can I improve the result?
Edit 1 : Adding the code used to generate Gaussian signal. Was using matlab.
fs = 200; % Sampling frequency
t1 = 1/fs : 1/fs : n1/fs; % Where n1 is the length of the square wave signal
s2 = 4*gaussmf(t1, [ 0.4 4.5 ]); % Generating Gaussian signal
Edit 2 : Adding code used to generate square wave. I am afraid, it's a clumsy code!
fs = 200; % Sampling Frequency
t = 1/fs : 1/fs : 3;
n = length(t);
sq(1 : round(n/3) ) = eps;
sq( (round(n/3) + 1) : 2*round(n/3) ) = 3;
sq( (2*round(n/3) + 1) : n ) = eps;
sq( (3*round(n/3) + 1) : 4*round(n/3) ) = 3;
sq( (4*round(n/3) + 1) : 5*round(n/3) ) = eps;
sq( (5*round(n/3) + 1) : 6*round(n/3) ) = 3;
sq( (6*round(n/3) + 1) : 7*round(n/3) ) = eps;
sq( (7*round(n/3) + 1) : 8*round(n/3) ) = 3;
sq( (8*round(n/3) + 1) : 9*round(n/3) ) = eps;