DSPRelated.com
Forums

Applying FFT on the data obtained from oscilloscope

Started by yeok...@ntu.edu.sg October 19, 2006
Hi all,
Firstly I would like to apologise if this message appears to be a repost. Anyway I saved data of a sine wave from the Agilent oscilloscope and imported it into MATLAB. I have 2 sets of data, one is the timing data and one is the amplitude data.

My task is to obtain the fourier transform for the sine wave and analyse the harmonic content of the wave. I can apply the fft function in MATLAB to the amplitude data but I am not sure how to incoperate the timing data to plot the frequency response.

Specifically, if I have a 8kHz sine wave, applying the fourier transform should give me a peak at frequency 8kHz and if the waveform is not pure, i should be able to see peaks at 16kHz, 32kHz... etc right? So my question is how do i use the amplitude and timing data obtained to plot out such a frequency response curve. Thanks
--- In m..., yeok0001@... wrote:
>
> Hi all,
> Firstly I would like to apologise if this message appears to be a
repost. Anyway I saved data of a sine wave from the Agilent
oscilloscope and imported it into MATLAB. I have 2 sets of data, one
is the timing data and one is the amplitude data.
>
> My task is to obtain the fourier transform for the sine wave and
analyse the harmonic content of the wave. I can apply the fft function
in MATLAB to the amplitude data but I am not sure how to incoperate
the timing data to plot the frequency response.
>
> Specifically, if I have a 8kHz sine wave, applying the fourier
transform should give me a peak at frequency 8kHz and if the waveform
is not pure, i should be able to see peaks at 16kHz, 32kHz... etc
right? So my question is how do i use the amplitude and timing data
obtained to plot out such a frequency response curve. Thanks
>

Hi all,
I'm a new comer. I jointed this group to my Matlab level & also my
english.
Your question is a typical problem in signal treatment (my work's also
related with signal treatment). You can try the codes below :

% Testing datas :
timing_data = 0:0.01:5;
amplitude_data = sin(2*t/0.1*pi); % 10 Hz sine wave

X = timing_data; %(s)
Y = amplitude_data; % linear scale
N = length(X);

delta_t = mean(diff(X));
f_max = 1/delta_t; % max frequency (Sampling theory)

% Increase the time range to improve the precision in frequency domain
% Decrease the time step (supposed to be regular) to widen the
spectral range

% frequency scale
f_scale = linspace(0,f_max/2,floor(N/2));

spectrum= fft(Y)/N;

figure(1)
plot(X,Y)
figure(2)
plot(f_scale,abs(spectrum(1:length(f_scale))));
You can transfer the data to Matlab using any of the file handling functions. If I remember correctly there should be a function which specifically transfers data stored in 2 columns; one for time index and the other for measured signal. Once you have that, you can either make data blocks of manageable sizes (incase you have say 2 mins of signal sampled at 20 khz) and perform FFT on it. The inverse of difference between any 2 values of time index will give u the sampling rate (or u might even know it beforehand) and then you can plot the fft from -fs/2 to fs/2. Hope this answers your question.

y...@ntu.edu.sg wrote: Hi all,
Firstly I would like to apologise if this message appears to be a repost. Anyway I saved data of a sine wave from the Agilent oscilloscope and imported it into MATLAB. I have 2 sets of data, one is the timing data and one is the amplitude data.

My task is to obtain the fourier transform for the sine wave and analyse the harmonic content of the wave. I can apply the fft function in MATLAB to the amplitude data but I am not sure how to incoperate the timing data to plot the frequency response.

Specifically, if I have a 8kHz sine wave, applying the fourier transform should give me a peak at frequency 8kHz and if the waveform is not pure, i should be able to see peaks at 16kHz, 32kHz... etc right? So my question is how do i use the amplitude and timing data obtained to plot out such a frequency response curve. Thanks