# aliasing to a 50 Hz sine wave sampled at 5000 Hz sampling rate?

I sampled a 50Hz sine wave (its not perfectly a sine wave, it's a data coming from current sensor using Arduino).

Using real time graphing technique by sending the data from Arduino to the PC I managed to reconstruct the signal as attached here The second experiment I logged my data into an SD card, my sampling rate was 5000 and when I tried to reconstruct the signal in MATLAB, I got this graph which doesn't construct the original signal back, but rather its strange as bellow: Notice the maximum values for the both graphs.

Why the signal is not correctly reconstructed? I sampled it at 5000 Hz which is almost 10 times the original signal frequency and it meets Nyquist criteria ... And as a result of wrongly constructed signal the FFT is indicating the frequency of zero not 50 Hz.

The MATLAB code

filename = 'C:\Users\Sabir\Desktop\internship Sri Wawasan\testFFT.csv';

% thee file

fid = fopen(filename,'rt');
[data]=textscan(fid, ' %f',...%the values of the sensors as cell array
'delimiter',',')  ;
fclose(fid);

sensorMatrix=cell2mat(data);

% the values of the sensors as matrix

%taking some point from the sensors matrix

y=sensorMatrix(1:3000,1);% array of one chanel

plot (y)

L=length(y)

Fs = 5000;                    % Sampling frequency

T = 1/Fs;                     % Sample time              % Length of signal

t = (0:L-1)*T;                % Time vector

plot(Fs*t,y)


and finally here is the FFT, it has 100 Hz and 150 Hz components • Your signal might have a fundamental frequency of 50Hz, but it can also contain higher frequencies (see Fourier series), since you signal has some characteristics of triangle wave it will contain a lot of higher frequencies. Mar 25 '15 at 13:16
• Your Matlab graph looks completely fine to me. The x-axis is in samples, which makes a period of about 100 samples, which is correct since your sampling rate is 100 times the main signal frequency. The voltage range is also consistent with the previous plot. Btw., for spectral analysis, don't use fft, use pwelch and friends. Mar 25 '15 at 16:43
• @fibonatic I analysed the signal using FFT, and that is correct, it has 100 Hz and 150 Hz (2nd and 3rd harmonics), but the current shape of the wave indicates lower frequency component ~2Hz and one of the reasons maybe is due to the sensor I am using, it may have some noise. If you by any chance interested here is a discussion about the issue sensors point of view openenergymonitor.org/emon/node/10382#comment-29040 Mar 27 '15 at 1:33
• hey @A. Donda why should I use pwelch and not fft I may post the fft analysis in an answer since I can't post a picture in a comment Mar 27 '15 at 1:37
• Sabir, spectral estimation via simple Fourier Transform has many drawbacks, the most obvious can be seen in your plot: Around each peak you have many sidelobes. This method is called the periodogram, and there are several improvements upon the periodogram. See en.wikipedia.org/wiki/Spectral_density_estimation#Techniques and follow the links on the periodogram and Welch's method. Mar 27 '15 at 15:53