7 views (last 30 days)

Show older comments

Hi, I have been trying to understand effects of the sampling frequency to the time axis plots and it got me curious that why we have "corrupted" data points in the plotted figures although we have Fs > 2* (signal frequency). FFT results and plots are expected, but I could not understand the "corruption" in the time domain plots ( or the visual effect - it is not like a cosine anymore). Is there any mathematical reasons that 1kHz or 2kHz samping frequencies are not enough to visualize a cosine signal with 350 Hz. Here is my simple testing code:

L = 800;

Fs = [1e3 1.5e3 2e3 4e3 8e3 16e3 24e3];

for index=1:length(Fs)

Ts = 1/Fs(index);

x = (0:L-1)*Ts;

f = 350;

y = .5*cos(2*pi*f*x);

figure

plot(x(300:450),y(300:450))

title("Fs = " + string(Fs(index)))

end

Star Strider
on 18 Sep 2021

Edited: Star Strider
on 18 Sep 2021

I believe this is simply an interaction of the sampling frequency and the signal frequency, typically referred to as ‘aliasing’.

I did the Fourier transforms to see if I could detect any irregularity, and the only finding was that the frequencies do not appear to be what they are intnded to be.

L = 800;

Fs = [1e3 1.5e3 2e3 4e3 8e3 16e3 24e3];

for index=1:length(Fs)

Ts = 1/Fs(index);

x = (0:L-1)*Ts;

f = 350;

y = .5*cos(2*pi*f*x);

figure

plot(x(300:450),y(300:450))

title("Fs = " + string(Fs(index)))

xc{index} = x;

yc{index} = y;

end

for index=1:length(Fs)

Fn = Fs(index)/2;

N = 2^nextpow2(numel(yc{index}));

FTy = fft(yc{index},N)/numel(yc{index});

Fv = linspace(0, 1, fix(N/2)+1)*Fn;

Iv = 1:numel(Fv);

figure

plot(Fv, abs(FTy(Iv))*2)

title("Fs = " + string(Fs(index)))

end

EDIT — (18 Sep 2021 at 17:44)

Changed:

FTy = fft(yc{index})/N;

to:

FTy = fft(yc{index},N)/numel(yc{index});

.

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

Start Hunting!