0
votes

I'm trying add two sine waves of different frequencies together and then use a butterworth filter to separate them again. I'm having trouble figuring out what to set the high and low cutoff to. Here is the code I've been playing with.

x = 0:.1:40*pi;

% Plot sine wave
subplot(3,1,1)
plot(x, sin(x));
ylim([-2 2])

wave = sin(x) + 2*cos(x/3);

% Plot mixed wave
subplot(3,1,2)
plot(x, wave);

[c d] = butter(5, [.02 .05]);
y2 = filtfilt(c, d, wave);

% Plot recovered wave
subplot(3,1,3)
plot(x, y2);

If I just wanted to get the normal sine wave wouldn't the frequency be 0.1/(2*pi) or ~0.016? After manually trying values for the cutoff, I found that 0.02 and 0.05 gives me what I want. But 0.016 is outside of that range.

What am I doing wrong?

1

1 Answers

0
votes

Your sampling frequency appears to be 10Hz (x = 0:.1:40*pi; so dt is 0.1s). So 0.02 cut-off corresponds to 0.02*2*pi*10 = 1.25 rad/s or 0.2 Hz.