Converting discrete signal to frequency domain
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi i am new to Matlab. My question is if i have a discrete signal (experiment data) stored in a variable like
onetrial = 1x200;
sampled a frequency of 100hz. How can i convert it into frequency domain and plot it.
Also how can i go about plotting its PSD(power spectral density)?
Thanks in advance.
0 Commenti
Risposta accettata
Star Strider
il 7 Mag 2022
The fft calculation an plotting is straightforward. (You can also use the pspectrum function and others.)
Fs = 100;
Fn = Fs/2;
Ts = 1/Fs;
t = linspace(0, 199, 200)/Fs; % Time Vector
onetrial = sin(2*pi*10*t) + randn(1,200)*0.1; % Signal Vector
L = numel(t);
NFFT = 2^nextpow2(L); % Fourier Transform Length Power-Of-Two For Efficiency
FT_onetrial = fft(onetrial - mean(onetrial), NFFT)/L; % Fourier Transform
Fv = linspace(0, 1, NFFT/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FT_onetrial(Iv))-2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!