# How to calculate the spectrum of a signal in CSV file?

77 views (last 30 days)
Florentino Ruiz on 17 Mar 2011
I'm working on a project whose aim is to develop measurements of acceleration with an accelerometer, I have made ??measurements 10.24kS sampled, stored in CSV files, measurements were performed for two seconds, which means I have 20.48 kS. I need to convert the acceleration signal to a new speed signal using integration. Then I apply the FFT to acquire the spectrum of the speed signal with a Hanning or Hamming window. But I do not know how to do any of these steps. If anyone has any idea how to do it, I appreciate your help.

vsee on 7 Apr 2011
Hello
I have a similiar situation. I have a signal stored in a csv file. The sample interval is 2us which means a sample taken every 2 micro seconds. I have a million sampples in the file. Essentially the signal is in the time domain (x(t) vs t). I have to acquire the spectrum of the signal to analyze it. Can you please explain how to do this?
Walter Roberson on 7 Apr 2011

Walter Roberson on 17 Mar 2011

#### 1 Comment

Florentino Ruiz on 17 Mar 2011
Thank you for your answer, now i have idea for my proyect.
close all
clear all
clc
Fs = 10240; % Sampling frequency
T = 1/Fs; % Sample time
L = 20480; % Length of signal
t = (0:L-1)*T; % Time vector
figure (1)
plot(t,axmacovel(1:L))
% plot(Fs*t(1:L),axmacovel(1:L))
xlabel('Tiempo (s)'), ylabel('Velocidad mm/s RMS'), grid on
% NFFT=2^nextpow2(L); % Siguiente pot de 2 de la long de 'y'.
Y=fft(axmacovel); % Aplica Transformada de Fourier.
% f=Fs/2*linspace(0,1,NFFT/2); % Vector de frecuencias.
f=Fs/2*linspace(0,1,L/2);
figure (2)
% plot(f,2*abs(Y(1:NFFT/2))),
plot(f,0.707*abs(Y(1:L/2)))
title('Espector de la Señal'),
xlabel('Frecuencia (Hz)'), ylabel('Velocidad mm/s RMS'), grid on
axmacovel is on my workspace of matlab, this variable was adquired manually: File-Import Data, etc. This axmacovel signal is the integration of the original acceleration signal, but i will have this manually. I don´t know if i used fft function correctly, because the level of signal in espectrum are different as i have in a Labview program.