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?
0 个评论
回答(1 个)
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);
You can refer to the following MathWorks documentation link for more insights on “FrequencyResolution”:https://www.mathworks.com/help/releases/R2021a/signal/ref/pspectrum.html?searchHighlight=pspectrum%20%26quot%3B%2Cfrequency%26quot%3B%20resolution&s_tid=doc_srchtitle#d123e133022:~:text=%CF%80%20rad/sample.-,%27FrequencyResolution%27,-%E2%80%94%20Frequency%20resolution
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!