Suppose that the signal corresponds to daily values during the year (365 days). It consists of all zeros, with the exception of several sparse values that correspond to isolated peaks divided by the same interval (30 days). I get a frequency spectrum with a fast Fourier transform function.
How to get rid of a peak with a high 0 Hz? EDIT : this is due to a non-zero signal value. See this post for more details.
The first peak is then at 12 Hz, which is somehow expected. However, peaks are also present at 24 Hz, 36 Hz, 48 Hz .... Is this a smoothing problem? How to get rid of it?
Below is my code. It has been tested in Octave, but it should also work in Matlab
close all clear all T = 1/365; % period samp_freq = 1/T; % sample frequency t=0:T:2; % overall time span is two years % build signal x= zeros(length(t),1); for i=1:length(t) if mod(i,30) == 0 x(i) = 100; else x(i) = 0; end end figure(1) plot(t,x) grid xlabel("Time [years]") ylabel("Signal amplitude") y=fft(x); N = length(x); for i=1:N f(i) = (i-1)*samp_freq/N; end figure(2) plot(f,abs(y)) xlabel("Frequency") ylabel("Signal amplitude") figure(3) plot(f(1:80),abs(y(1:80))) xlabel("Frequency") ylabel("Signal amplitude")


source share