Why does frequency of complex exponential doubles when frequency increases?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Clement
el 15 de Oct. de 2024
Comentada: William Rose
el 16 de Oct. de 2024
Hello,
Let me first give the general context. I am currently on a code to generate and detect the frequency shift generated by the Doppler effect of a moving object. So my basic idea was to generate a baseband complex signal emitted by the moving object , and then multiply it by a complex exponential of which the phase corresponds to the frequency shift of the doppler effect, such that the resulting frequency-shifted signal y is:
Now, since the object is moving, is a function of time and changes for each signal sample, so the correct equation would be:
This brings me to my current issue. I have a code that generates the complex exponential in charge of the phase shift based on a vector containing the doppler shift frequencies for each signal sample. To make it simple, the frequency shifts increase linearly from 0 to 100 Hz. But when I plot the sprecturm of the obtained complex exponential , the sectrum spans up to 200 Hz.
I cannot figure out if this is due to me no understanding the math properly, a code error, or a Matlab issue.
Note that if I change the doppler shift frequency to contain a constant value, e.g. 50Hz, then the spectrum displays a spike at 50 Hy, as expected.
Please find below the code to reproduce my issue:
F = 1e6; % Symbol rate
Fs = F * 4; % Sampling frequency
Ts = 1 / Fs; % Sampling period
n_samples = 4000000;
time = (0:n_samples-1) * Ts; % Time vector
doppler_shift = 50.*ones(1,length(time));
phase_rotation = exp(1j * 2 * pi * doppler_shift .* time).'; % Complex signal
Y = fft(phase_rotation, 2^(1 + ceil(log2(Fs)))); % FFT
P2 = abs(Y);
L = length(P2);
P1 = abs(fftshift(Y)); % Shifted FFT
f = Fs / L * (-L/2:L/2-1); % Frequency vector
% Plotting the spectrum
figure;
plot(f, P1); % Spectrum plot
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Constant Doppler shift');
xlim([0 2*max(doppler_shift)])
doppler_shift = 100 * (1:length(time)) / length(time); % Frequency array
phase_rotation = exp(1j * 2 * pi * doppler_shift .* time).'; % Complex signal
Y = fft(phase_rotation, 2^(1 + ceil(log2(Fs)))); % FFT
P2 = abs(Y);
L = length(P2);
P1 = abs(fftshift(Y)); % Shifted FFT
f = Fs / L * (-L/2:L/2-1); % Frequency vector
% Plotting the spectrum
figure;
plot(f, P1); % Spectrum plot
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Variable Doppler shift');
xlim([0 2*max(doppler_shift)])
0 comentarios
Respuesta aceptada
William Rose
el 15 de Oct. de 2024
Editada: William Rose
el 15 de Oct. de 2024
[Edit: Fix spelling mistakes; no changes to equations or to code.]
your code is good. The unexpected result is due to the math. Consider the following example. I will describe an approach to synthesizing a signal. The approach yields a signal whose frequency increases twice as much as expected. Then I will explain the reason.
I want to generate a sinusoidal signal that starts with frequency f=100 Hz and increases linearly to 200 Hz in 1 second. My mathematical model of the signal is , where f is a linearly increasing function of time:. In this case I want f0=100 Hz and k=100 Hz/s, so that the frequency is 200 Hz after 1 second has passed.
t=0:.0004:1;
f0=100; % initial frequency (Hz)
k=100; % rate of change of frequency (Hz/s)
x=cos(2*pi*(f0+k*t).*t);
% plot full length signal and plot the beginning and the end
subplot(211), plot(t,x,'-r'); grid on; xlabel('Time (s)');
subplot(223), plot(t,x,'-r'); grid on; xlabel('Time (s)'); xlim([0 .01])
subplot(224), plot(t,x,'-r'); grid on; xlabel('Time (s)'); xlim([.99 1])
Examination of the two bottom plots shows that the signal frequency is 100 Hz at t=0, as expected, and the frequency is 300 Hz when t=1, which was NOT expected. I expected the frequency to be 200 Hz at t=1.
The explanation for the unexpected result is as follows:
The frequency of a sinusoidal signal equals the rate of change of phase.
where fm is the measured frequency in cycles/s and is the instantaneous phase, in radians:
In this case, . Therefore . Therefore the measured frequency at time t is
Note the factor of 2 in the right-most equation above. This factor of 2 explains why the frequency goes up by 200 Hz in 1 second, when we only expected it to go up by 100 Hz.
The explanation above also explains your situation, in which the measured frequency of the signal increases twice as fast as you expected.
3 comentarios
William Rose
el 16 de Oct. de 2024
@Clement, you are welcome. I think you and I are not the only ones who have made this error.
Más respuestas (0)
Ver también
Categorías
Más información sobre Transmitters and Receivers en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!