Skip to content

Instantly share code, notes, and snippets.

@ppizarror
Last active September 28, 2019 00:31
Show Gist options
  • Save ppizarror/23f8920aea2b2bb11035320bf1728804 to your computer and use it in GitHub Desktop.
Save ppizarror/23f8920aea2b2bb11035320bf1728804 to your computer and use it in GitHub Desktop.
Obtener FFT de un registro [Matlab]
% Carga el registro
data = detrend(load('accRoca.txt'), 0);
FS = 200; % Muestreo, 200 datos por segundo
% Encuentra la potencia que mas se ajusta al numero de datos
n = 2^nextpow2(length(data));
% Crea el vector temporal
tdata = zeros(n, 1);
for j = 2:n
tdata(j) = tdata(j-1) + 1 / FS;
end
w = FS * (0:(n / 2)) / n; % Vector de frecuencias
% Calcula la fft del registro
fft_ = fft(data, n);
fft_registro = fft_(1:n/2+1); % Selecciona la mitad
tdata = tdata(1:n/2);
fig = figure(1);
set(gcf, 'name', 'FFT registro');
movegui(fig, 'center');
plot(w, abs(fft_registro), 'k');
xlabel('Frecuencia (hz)');
ylabel('FFT (g\cdot s)');
title('FFT Registro');
hold off;
grid on;
grid minor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment