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

4 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Yukthi S
Yukthi S el 16 de Feb. de 2024
Editada: Rena Berman el 16 de Jul. de 2024
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);

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by