LOMBSCARGLE(INPUTDATA, DUPE_ELIM) performs a Lomb-Scargle periodogram (spectral) analysis on an n x 2 matrix of data (inputdata = x(i),y(i)) that are not necessarily evenly spaced. (For evenly spaced data, more traditional Fourier-based spectral methods may be more appropriate.)
DUPE_ELIM (= 0 or 1) is an optional argument that will prompt the program (if dupe_elim == 1) to eliminate duplicated samples from the analysis. The default value is 0.
This program will plot and spectrally analyze the input data, and then plot the power spectrum of the data.
The program is also capable of overlaying a signal of known frequency and amplitude; this may be helpful for spectral calibration. The resulting spectrum plot will also include significance levels. Finally, the program will reconstruct a plot of frequencies determined to be "significant" (at alpha = 0.05); for this reconstruction, frequencies within 5% of the calibration signal (if used) will be discarded. Significant frequencies and powers are written to the MATLAB command window.
(This program is based on a Lomb-Scargle implementation in Press, Teukolsky, et al. Numerical Recipes, "Spectral Analysis of Unevenly Sampled Data." Use of this program requires an understanding of the Press/Teukolsky implementation, inculding the usage of hifac and ofac variables. The user is referred to that source for a thorough discussion of the algorithms. In addition, the references cited in Press/Teukolsky are quite helpful--particularly Scargle 1982, and Horne and Baliunas, 1986.)
Note that there is an over-reliance in this code on global variables, and that no attempts have been made to vectorize for loops or to optimize the implementation. Perhaps in the next version....
The attached file INPUTTOLOMB.M includes code for easily generating test data with known frequencies and amplitudes. This file is helpful for users trying to understand the output generated by lombscargle.
Brett Shoelson (2020). lombscargle.m (https://www.mathworks.com/matlabcentral/fileexchange/993-lombscargle-m), MATLAB Central File Exchange. Retrieved .
Hi everybody. Quick question: Is there any restriction to define hifac or fhi? I am trying to use the code but I get the following message:
Error using drawnow
Undefined function 'gethifac' for input arguments of type 'char'.
Error using lombscargle>gethifac (line 465)
Error while evaluating UIControl Callback.
Error using matlab.ui.control.UIControl/get
Invalid or deleted object.
Error in lombscargle>gethifac (line 464)
Error in lombscargle>period (line 267)
hifac2 = gethifac;
And I am using a fhi smaller than Nyquist frequency....
Thank you in advance for your help.
Unfortunately, I am unable to support this piece of code. I wrote it VERY long ago, haven't touched it in a long time. The best I can do is (re-)steer you to the reference cited above. As for the calibration, that's my own implementation, and I don't know exactly how mathematically "rigorous" the idea is. The amplitude of peaks in the spectrum is only relevant relative to the amplitudes of other peaks. My thought was to add to the data a stationary signal of a know amplitude and frequency. The resulting "reference peak" would help to scale, or "calibrate," the spectrum of the data.
Excellent program! But how to realise an analyse of a phase shifted data input?
Hi could not get the use of calibration frequency and calibration amplitude? plz help.
Great piece of code!
it seems that the significant level strongly depends on the time resolution of the input. How to resolve this problem?
I have problems with the inputdata prcedure. How should I input my n*2 matrix?
i have 538 data points and i need analyse these data. But when i entering hifac=1548 programme did't work, so i need fast computation for this value.
i still learning about this topic.
thanks for help me to understand and use this file.
Works exactly like it supposed to. It would be nice to output the raw spectrum data to a matrix.
Well done. The significance levels on the spectral plot are especially useful.
two functions with the same name ("period") so won't run...
Inspired: Lomb normalized periodogram
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!