Sampling frequency and correct signal plotting

126 visualizaciones (últimos 30 días)
Berkay Yaldiz
Berkay Yaldiz el 18 de Sept. de 2021
Comentada: Berkay Yaldiz el 20 de Sept. de 2021
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

Respuesta aceptada

Star Strider
Star Strider el 18 de Sept. de 2021
Editada: Star Strider el 18 de Sept. de 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});
.
  10 comentarios
Paul
Paul el 19 de Sept. de 2021
Editada: Paul el 19 de Sept. de 2021
That comment seemed to be talking about visualization in the frequency domain, because it referenced Fourier transform results and harmonics.
But it sounds like the real concern is how the signal is visualized in the time domain using Matlab's plot() command? If that's the case, the look of the plot is determined by how plot() fills in the space between the sample points that are input to the plot() command. Perhaps I still don't understand exactly what the desired or expected result is.
Berkay Yaldiz
Berkay Yaldiz el 20 de Sept. de 2021
Hi, yes plot command fills the space between sample points, but for "relatively" lower sampling frequencies, although these frequencies are higher than the minimum required frequencies to not have aliasing, we observe more like a noise rather than a cosine waveform and this issue stuck in my mind, that is why I used that term. Hence, we checked Fourier domain to see if anything went wrong.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by