フィルターのクリア

Converting discrete signal to frequency domain

7 ビュー (過去 30 日間)
Adnan Abid
Adnan Abid 2022 年 5 月 7 日
回答済み: Star Strider 2022 年 5 月 7 日
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.

採用された回答

Star Strider
Star Strider 2022 年 5 月 7 日
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.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by