Sampling frequency and correct signal plotting

조회 수: 34 (최근 30일)
Berkay Yaldiz
Berkay Yaldiz 2021년 9월 18일
댓글: Berkay Yaldiz 2021년 9월 20일
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
Star Strider 2021년 9월 18일
편집: Star Strider 2021년 9월 18일
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
Paul
Paul 2021년 9월 19일
편집: Paul 2021년 9월 19일
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 2021년 9월 20일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Frequency Transformations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by