I have my information frequency, and carrier frequency. I modulate the signal and add noise. After I do that I run it through a halfwave rectifier and low pass and high filter. I then use a convolution to remove the noise. I then write the file to a wave file and I should be able to replay file. At the end of all this I should get something similar to the original frequency, but all I'm getting is static.

Here's my code.

close all;

clear all;

fs = 50000;

t = [0:1/fs:5];

f_cut_off1 = 10000;

f_cut_off2 = 10;

f = 2000; %input frequency

fc = 940e3; %carrier frequency

k = length(t)

input_sig = (0.2)*cos(2 * pi * f * t); %input signal

wavwrite(input_sig,fs,32,'input_sig');

carrier_sig = (0.5)*cos( 2 * pi * fc * t); %carrier signal

wavwrite(carrier_sig,fs,32,'carrier_sig')

mod_sig = input_sig .* carrier_sig + carrier_sig; %modulated signal

wavwrite(mod_sig,fs,32,'mod_sig')

%interval to randonize noise

noise = rand(1, k); %random nosie

scale = 2;

new_mod = mod_sig + noise; % mod signal + noise

wavwrite(new_mod,fs,32,'new_mod')

subplot(321), plot(t, mod_sig)

subplot(322), plot(t, new_mod)

%Apply HW Rectifier

for i = 1:k

if new_mod(i) <= 0

x(i) = 0;

else

x(i) = new_mod(i);

end

end

wavwrite(x,fs,32,'hw_rect')

subplot(323), plot(t, x)

rc1 = 1 / (2 * pi * f_cut_off1);

rc2 = 1 / (2 * pi * f_cut_off2);

%Apply Low Pass Filter

num2 = [0 1];

den2 = [rc1 1];

subplot(324), bode(num2, den2)

sys2 = tf(num2, den2);

lpf = lsim(sys2, x, t);

%Apply High Pass Filter

num1 = [rc2 0];

den1 = [rc2 1];

subplot(325), bode(num1, den1)

sys1 = tf(num1, den1);

hpf = lsim(sys1, lpf, t);

vout = hpf;

g = 20;

h = (1 / g) * ones(1, g);

y = conv(h ,vout);

wavwrite(y,fs,32,'vout')

Any ideas? I'm completely stuck.

Thanks!