Time to frequency domain
Mostrar comentarios más antiguos
Hi guys I have to convert the signal generated from accelerator(recorded in xls file) which is in time series to freq domian. So far I did this
% read data
data = xlsread('X');
%Frequency Analysis
time = data(:,1); % sampling time
signal = data(:,2); % signal data in Time-Domain
Ts=time;
Fs=20000; % sampling frequency
Now I want to convert this time signal to frequency signal with filtering . What should I do to get Frequency domain and filtering. Thank you in advance.
1 comentario
krn99
el 4 de Abr. de 2017
Hello can any one say the difference between 1st part fft code and 2nd part 1, X=load('EMG_neurogenic.txt'); Fs=1000; L=length(X); Y = fft(X); P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(L/2))/L; plot(f,P1)
2, Ts = mean(diff(time)); % Sampling Interval Fs = 1/Ts; % Sampling Frequency Fn = Fs/2;
FT_Signal = fft(signal)/N; % Normalized Fourier Transform Of Data Fv = linspace(0, 1, fix(N/2)+1)*Fn; % Frequency Vector (For ‘plot’ Call) Iv = 1:length(Fv);
figure(1) plot(Fv, abs(FT_Signal(Iv))*2)
Respuesta aceptada
Más respuestas (2)
jagadeesh jagadeesh
el 28 de Oct. de 2019
1 voto
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
figure(1)
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)'
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
figure(2)
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
Richard Zappulla
el 29 de Mzo. de 2017
0 votos
Hi,
For converting the data to the frequency domain, I would suggest using the fft() function. The examples from the MATLAB documentation on this function will form a good template for you (fft documentation webpage: FFT documentation).
As far as filtering the data, you can potentially use filteredData = filter(b,a,rawData), where b and a are the numerator and denominator coefficients of the filter. As far as determining the coefficients, that is problem specific. Results of the FFT of the raw data will help inform the selection of your coefficients.
Hope this helps!
1 comentario
s p
el 29 de Mzo. de 2017
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!