TimeseriesFromPSD(S​xx, fs, T, plot_on)

버전 1.5.0.0 (4.94 KB) 작성자: Michael
Create timeseries from a given double-sided PSD
다운로드 수: 1.6K
업데이트 날짜: 2015/6/29

라이선스 보기

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 릴리스 호환 정보
개발 환경: R2014a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

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