fft showing frequency components at double rates
33 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sina
el 4 de En. de 2022
Comentada: Sina
el 2 de Feb. de 2022
Hi there
worked with Lumerical (photonic simulating software) i got a output Time domain-signal and wanted to see it's spectrum via fft , so i used fft but the plot is showing me components at double rate which lumerical moniter visualizing spectrum shows the right spectrum, so i wondered why it is, if you have an experince or such it would be great , and Here's my code for making this happen:
clear all
close all;
% rng('default')
% fs = 100; % sample frequency (Hz)
% t = 0:1/fs:10-1/fs; % 10 second span time vector
% y = (1.3)*sin(2*pi*15*t) ... % 15 Hz component
% + (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component
% + 2.5*randn(size(t)); % Gaussian noise;
%
% figure(1)
% plot(t,y)
load TE0_time_signal.mat;
t=lum.x0;
y=lum.y0;
figure(1)
plot(t,y)
grid on
xlabel('Time in s')
ylabel('Output field Magnitude')
time_step=t(2);
fft_y = fft(y);
%
fs=1/time_step;
% [A,B,C,D] = butter(20,[192.668e+12 192.945e+12]/fs);
% d = designfilt('bandpassiir','FilterOrder',20, ...
% 'HalfPowerFrequency1',192.668e+12,'HalfPowerFrequency2',192.945e+12, ...
% 'SampleRate',fs);
n = length(y); % number of samples
f = (0:n-1)*(fs/n); % frequency range
power = abs(fft_y).^2/n; % power of the DFT
figure(2)
plot(f,power)
xlabel('Frequency')
ylabel('Power')
%
y0 = fftshift(fft_y); % shift y values
f0 = (-n/2:n/2-1)*(fs/n); % 0-centered frequency range
power0 = abs(y0).^2/n; % 0-centered power
figure(3)
plot(f0,power0)
xlabel('Frequency')
ylabel('Power')
as you can see plot worked and showed the frequency components for my output time-signal
at the top of script (comment lines) i added a sinus function to test this script and it works well and shows right components, i got this script from mathworks platform,
My script should show frequncy components at 192.806 THz , 193.431THz ,194.055 THz but shows these at 385.612 THz, 386.862 THz , 388.11 THz (around 0.3e+15 in plot)
can somebody tell me why is that? And How it can be solved right to get right plot?
i have a guess which may be relevent that Nyquist theorm for complex signals states that the fsampling is maximum frequency that you can show unambigiously which in real signals are fsampling/2
Thanks
0 comentarios
Respuesta aceptada
David Goodmanson
el 4 de En. de 2022
Editada: David Goodmanson
el 4 de En. de 2022
Hi Sina,
Here is an observation and a possible answer. If you expand out plot(t,y) (I used
xlim([4 4.1]*1e-12) )
there are about 4 cycles in 10^-14 sec, or 400 THz, I think the fft is working correctly, given what its input is. However, you say you are fft-ing the magnitude of the signal. To me y doesn't look exactly like the magnitude of a signal might, but it is certainly always positive.
If you do an fft on a signal cos(2*pi*f0*t) you of course get peaks at +-f0. But abs(cos(2*pi*f0*t)) has twice as many oscillations per unit time as does cos(2*pi*f0*t). So you get peaks at 2*f0, plus a bunch of other smaller peaks that don't really seem to be showing up.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!