Calculate PSD and plot smooth curve
114 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Wayne King
il 30 Nov 2011
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 Commenti
Più risposte (4)
Wayne King
il 30 Nov 2011
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 Commenti
Wayne King
il 1 Dic 2011
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 Commenti
Vedere anche
Categorie
Scopri di più su Parametric Spectral Estimation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!