필터 지우기
필터 지우기

Adding Random phase causes fft anomalies?

조회 수: 6 (최근 30일)
Nathan Kennedy
Nathan Kennedy 2017년 12월 14일
답변: Joel Miller 2017년 12월 14일
Hi
If I add random_phase to my waveforms then the fft goes skewy - basically it breaks down and is not producing what it should be like when random_phase is not present in sinewave generation loop.
%Setup sampling times and frequency range
f=(20.2 : 0.1 : 21.1)*10^9;
Fs = 3*max(f);
Ts = 1/Fs;
end_t = 0.5*10^-6
dt=0: Ts : end_t -Ts
a=0; b=pi; %for random phase calculation
%Below part adds a new sine wave every 0.01*10^9 within frequency range
for a=1:length(f)-1
random_phase = (b-a).*rand(1,length(dt))+a;
y(a,:) = 5*sin(2*pi.*f(a) .* dt + random_phase); %remove random_phase and scripts works fine.
end
%combined waveform
waveform = sum(y);
%setup frequency domain for FFT
N=length(waveform);
freq_domain = (0:N-1);
freq_domain = f_domain*Fs/N
ft=2*abs(fft(waveform)/N);
figure(1)
bar(freq_domain, ft);
ax=gca; ax.XAxis.Exponent = 9;
xlim([20 *10^9 21.4*10^9]);
Completely stumped how random phase messes up my fft...

채택된 답변

Star Strider
Star Strider 2017년 12월 14일
The random phase will shift your sine curve randomly in time, essentially destroying the periodicity. You can see this easily if you plot your signal in the time domain:
figure(2)
plot(dt, waveform)
grid
subplot(2,1,2)
plot(dt, waveform)
axis([0 2E-8 ylim])
grid
Also, if you use plot rather than bar, the Fourier transform is easier to see.

추가 답변 (1개)

Joel Miller
Joel Miller 2017년 12월 14일
If you are trying to randomly shift the phase of the sinusoids, sin(2*pi.*f(a) .* dt), then random_phase should be a scalar. When random_phase is a vector of length dt, you are adding a different phase to each time increment of the sinusoid. That is a reasonable definition of random (phase) noise. You can see this by fourier transforming just random_phase.

카테고리

Help CenterFile Exchange에서 Continuous Waveforms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by