Here's the equivalent in matlab: dt = 100e-6; %time interval t = 0:dt:250e-3; %sample steps freq1 = 697; freq2 = 770; freq3 = 853; %frequencies %below we generate the input signal in five steps sig(1:length(t)) = 0; sig(1:50e-3 / dt) = sin( 2*pi/freq1 * t(1:50e-3 / dt) ); sig(50e-3/dt : 100e-3/dt) = 0; sig(100e-3/dt : 150e-3/dt) = sin( 2*pi/freq2 * t(100e-3/dt : 150e-3/dt)); sig(150e-3/dt : 200e-3/dt) = 0; sig(200e-3/dt : 250e-3/dt) = sin( 2*pi/freq3 * t(200e-3/dt : 250e-3/dt)); k = 1/128; % filter constant f_a = [1 -2*(k-1) 1 ]; f_b = [ k^2 ]; %standardized filter coefficients for 2-pole filter mix_sin_in = sin(2*pi*freq2*t); %mixer input signals mix_cos_in = cos(2*pi*freq2*t); mixed_sin = mix_sin_in .* sig; %mixed signals mixed_cos = mix_cos_in .* sig; ff_sin = filter(f_b, f_a, mixed_sin); %do the filtering ff_cos = filter(f_b, f_a, mixed_cos); magsq = 4* ( ff_cos .^ 2 + ff_sin .^ 2; ) hold on plot(t, sig, 'r-'); plot(t, magsq, 'b-'); -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist