One way to do what I believe you want to do is to heterodyne your initial signal with the difference between it and the the new frequency. This is called ‘amplitude modulation’, and specifically here ‘double sideband suppressed carrier’ modulation. I then filter out the lower sideband to produce a ‘single-sideband suppressed carrier’ signal at the desired (upper sideband) frequency.
Don’t worry about the details. I’m simply explaining what my code does and how it works. My code requires the Signal Processing Toolbox to design and implement the filter.
The modulation technique multiplies two sinusoids of different frequencies together to produce sinusiods with the sum and difference of those frequencies. The mathmatical background is given in the Wikipedia entry on Product-to-sum and sum-to-product identities. The code:
Fs = 4.41E4;
tmax = 5;
t = linspace(0, tmax, tmax*Fs);
f = 220;
s = sin(2*pi*f*t + cos(15*pi*t)*pi/2);
sound(s, Fs)
pause(tmax*2)
Fc = 261.6;
carrier = sin(2*pi*(Fc-f)*t);
sm = s .* carrier;
Fn = Fs/2;
Wp = Fc/Fn;
Ws = Wp*0.8;
[n,Wn] = buttord(Wp, Ws, 1, 10);
[b,a] = butter(n,Wn,'high');
[sos,g] = tf2sos(b,a);
smf = 2*filtfilt(sos,g,sm);
sound(smf, Fs)
Fn1 = Fs/2;
Ft1 = fft(s)/length(s);
Fv1 = linspace(0, 1, fix(length(Ft1)/2)+1)*Fn1;
Ix1 = 1:length(Fv1);
Fn2 = Fs/2;
Ft2 = fft(smf)/length(smf);
Fv2 = linspace(0, 1, fix(length(Ft2)/2)+1)*Fn2;
Ix2 = 1:length(Fv2);
figure(1)
plot(Fv1, abs(Ft1(Ix1)))
grid
hold on
plot(Fv2, abs(Ft2(Ix2)))
hold off
axis([0 500 ylim])
Best Answer