I tried the following code for modulation of two analog waves. Can anyone point to how to modulate and demodulate for an analog and a digital wave? I tried by replacing the second signal (x2) with a digital pulse but I am not able to recover the analog wave after demodulation.
T = 1; Fs = 44100; t = 0:1/Fs:T; Fc = 17000; f1 = 100; x1 = sin(2*pi*f1*t); f2 = 200; x2 = sin(2*pi*f2*t); Cs = sin(2*pi*Fc*t); Cc = cos(2*pi*Fc*t); %%Modulation mod_wav = x1.*Cs + x2.*Cc; %%Demodulation demod_x1 = mod_wav.*Cs; demod_x2 = mod_wav.*-Cc; %%filter fpass = 10; fstop = 500; N = 30; b = firls(N,[0 fpass fstop Fs/2]/Fs/2, [1 1 0 0], [1 1]); filt_x1 = filter(b,1,demod_x1); filt_x2 = filter(b,1,demod_x2);
In the above code, if i use butter filter, then it is properly working but not if i use FIR like above. Why is that? In a broader sense, when to use butter and and when to use FIR filter?