QAM for analog and digital waves 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?
When I ran your code in Matlab I got the following warning message:

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =  6.912349e-21. 
&gt; In firls at 175 


It turns out that the problem is the "/Fs/2" part.  You are trying to normalize the frequencies from $0$ to $\frac{F_s}{2}$ into the range $0$ to $1$.  The problem is that Matlab divides the numbers in order, so even though what you want is /(Fs/2) what you are getting is /(Fs*2).  Changing the line to the following-

b = firls(N,[0 fpass fstop Fs/2]/(Fs/2), [1 1 0 0], [1 1]);


fixes the problem.