Create one realization of a timeseries from a given double-sided PSD, Sxx
NOTE: Since we don't have phase information, the original timeseries is
not recoverable. We can, however, create a random timeseries that has the
same statistical characteristics as the original timeseries.
Steps:
Create perfect white noise by generating random phase in the frequency
domain, and then multiply it by your PSD. Then transfer it to the time
domain...Take note that MATLAB expects the conjugate symmetric part of
the spectrum to be the second half of the array.
INPUTS
Sxx - Double-sided power spectral density in the expected MATLAB
order e.g. [wavePSD_positiveFreq wavePSD_negativeFreq]
fs - Sample rate of the output timeseries [samples/sec]
T - Desired length of the output timeseries [seconds]
OUTPUTS
timeseries - Generated timeseries
time - Time vector corresponding to timeseries generated
EXAMPLE
T = 100; % Length of timeseries
fs = 25; % Sample rate of timeseries
f0 = 2; % For this example, just do a tone
% Build PSD of a single tone in this example
rmsLevel = 1; % RMS level of tone
df = 1/T;
GxxMag = ((rmsLevel^2)/df); % Single-Sided Power spectrum magnitude
SxxMag = GxxMag/2; % Double-sided Power spectrum magnitude
PSD_DoubleSided = zeros(T*fs, 1);
PSD_DoubleSided(f0*T+1) = SxxMag;
PSD_DoubleSided(end-f0*T+1) = SxxMag;
[timeseries, time] = TimeseriesFromPSD(PSD_DoubleSided, fs, T); % Run!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright Mike Rudolph, 2014
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Last modified: July 29, 2014
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
引用格式
Michael (2024). TimeseriesFromPSD(Sxx, fs, T, plot_on) (https://www.mathworks.com/matlabcentral/fileexchange/47342-timeseriesfrompsd-sxx-fs-t-plot_on), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.5.0.0 | Version 2: resample Sxx based on input T |
||
1.4.0.0 | Added example in code, and made extra sure everything checks out based on what you input, and cleaned up comments. |
||
1.3.0.0 | Modified code and comments to make it easier to follow. Corrected some of the scaling factors so that generated timeseries is in the proper units and is scaled correctly. |
||
1.2.0.0 | Make sure you get back to original units in time domain. Take note the beginning and end will have ringing, an artifact of the IFFT. |
||
1.1.0.0 | Fixed error to PSD input definition. |
||
1.0.0.0 |