Effacer les filtres
Effacer les filtres

Converting discrete signal to frequency domain

7 vues (au cours des 30 derniers jours)
Adnan Abid
Adnan Abid le 7 Mai 2022
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.

Réponse acceptée

Star Strider
Star Strider le 7 Mai 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')
To calculate the PSD there are several options, one of which is the pwelch function.
.

Plus de réponses (0)

Catégories

En savoir plus sur Parametric Spectral Estimation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by