How to specify number of samples used to calculate the power spectrum using function pspectrum?

조회 수: 3 (최근 30일)
I have a time signal (sig20) of 65433 data points (N) that i read from an excel file, (i dont know if i can attach the file). The signal was measured with sampling frequency Fs of 31.25 kHz.
When i try to calculate power spectrum using :
Ts=3.2e-5;
Fs=1/Ts;
sig20=readtimetable("20.csv","TimeStep",seconds(Ts),"ReadVariableNames",true)
sig20.Properties.StartTime=seconds(-1);
[p(:,1),freq]=pspectrum(sig20.v0_8, Fs);
, it returns freq of size [4096x 1] and maximum frequency of 15.625 kHz. This means it has used 4096*2 = 8192 samples only which is quite less than the amount of data i have. I know this has been selected for practicality reasons. However, how to specify it to use for example 65432 data points (the nearest even number from my number of samples) in order to get the best frequency resolution?

답변 (1개)

Yukthi S
Yukthi S 2024년 2월 16일
편집: Rena Berman 2024년 7월 16일
Hi Shehab
I figure out that you were not able to use all the 65,432 data points to plot the power spectrum.
You can try including “FrequencyResolution in the input arguments of “pspectrum” to explicitly specify the number of data points to be used while plotting the spectrum.
You can modify the code as below:
[p(:,1), freq] = pspectrum(sig20.v0_8, Fs, 'FrequencyResolution', freqResolution);

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by