Calculate PSD and plot smooth curve
114 ビュー (過去 30 日間)
古いコメントを表示
Hey all,
I've new to matlab, and have been wrestling with processing and plotting PSD data. I have raw data (time and magnitude in g), as well as already processed data by different software (in freq and g^2/Hz). I'd like to compare PSDs from this software versus whatever I can cook up in matlab.
I need to take the raw data (in csv files, two columns, time and amplitude of g) and run a PSD on it. I'd then like to plot a smoothed version of the PSD to make a profile curve that represents most of the data (i don't want to plot the results of the PSD, too much info).
I've been trying to use different functions in matlab some of which seem obsolete or deprecated, so any help is appreciated, thanks!
JT
0 件のコメント
採用された回答
Wayne King
2011 年 11 月 30 日
Hi JT, you can use spectrum.periodogram and spectrum.welch
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t)+randn(size(t));
plot(psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(x)));
figure;
plot(psd(spectrum.welch,x,'Fs',Fs,'NFFT',length(x)));
0 件のコメント
その他の回答 (4 件)
Wayne King
2011 年 11 月 30 日
Hi, yes, you can just return the output from psd() and plot it as you wish.
psdest = psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(x));
plot(psdest.Frequencies, psdest.Data); grid on;
ylabel('g^2/Hz');
xlabel('Hz');
0 件のコメント
Wayne King
2011 年 12 月 1 日
Hi, you do not want to input test in this example, because test is a matrix. psd() expects a vector input, a 1-D signal. What you want to input is either x or y, whichever is the meaningful time series, also, for 'NFFT', you do not want to input a vector, like t =0:length(x). NFFT should just be a number, the number of FFT bins, use length(x), or length(y).
Finally, make sure that fs is your sampling frequency
'Fs',10000 or 'Fs',1 whatever the sampling frequency of your data is.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Parametric Spectral Estimation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!