I'm trying to frequency shift a sine wave at 50kHz by using a complex exponential at 15kHz. I should be getting an FFT with a peak at 65kHz.
Instead I'm getting a strange looking peak at 52.4kHz. Anyone know why this is?
This is probably a simple issue but I've been stuck for too long.
Here is my Matlab code:
clc,clear close all srate = 300e3; npnts = srate*5; %generate number of points for 5 seconds of sampling time = (0:npnts-1)/srate; % signal settings freq1 = 50e3; ampl = 1; signal = ampl*sin(2*pi*freq1*time); % amplitude spectrum via Fourier transform signalX = fft(signal); signalAmp = 2*abs(signalX)/npnts; % need to multiply by 2 to recover amplitude from negative freqs % divide by npnts to normalize fourier coefficients % shift signal using complex exp freq2 = 15e3; shift = exp(1i*freq2*time).*signal; signalshift = fft(shift); signalAmpshift = 2*abs(signalshift)/npnts; % vector of frequencies in kHz hz = linspace(0,srate/2,floor(npnts/2)+1)/1e3; %go from 0 to nyquist, frequency resolution is defined by last term ns=1; xlimits = [(freq1-ns*freq2)/1e3 (freq1+ns*freq2)/1e3]; figure(1); stem(hz,signalAmp(1:length(hz)),'ks','linew',2,'markersize',10) hold on stem(hz,signalAmpshift(1:length(hz)),'linew',2,'markersize',10) xlim(xlimits) legend({'Signal';'Shifted'}) 



