필터 지우기
필터 지우기

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 CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by