SINIDE - Parameter identification of a sine-wave from a measured signal

Frequency, amplitude, phase shift and mean value of the best sinus fit to a sampled signal.
1.3K Downloads
Updated 15 Jun 2015

View License

The function sinide is a robust replacement of the function sinfapm (FEX IDE 19902), which is rather sensitive to an initial guess of sine parameters. Results of all tested tasks were acceptable until Will Wehner supplied me two mat-files, which have shown that the sinide v.2.0 again does not supply right results. This was a reason why the atgorithm of the function has been completely rebuilt.

Now, the script sinidetest.m that comes with sinide.m has two branches. The first one starts with the prompt 'Load file'. The user may accept it by pressing ENTER key and then answer the second promt by entering the name of a file with an extension. Permitted extensions are .mat, .m, or any of text file extensions (.txt, .csv, .asc, ...). If extension is omitted, it is assumed that the program should load the mat-file of the given name, say 'y' or 'z', what means that files 'y.mat' or 'z.mat', which are included, be loaded and processed. Alternatively the user may enter any other name of mat-file supplied by him|her. The user's data file should provide a sampling frequency in variable fs, and vector of samples in variable y.

If the user refuses the offer from the first prompt by pressing any other key than ENTER, say 'n', the testing branch of the algorithm is entered. The user may accept offers of testing sine parameters by pressing ENTER keys, or some of them modify from a keyboard. The precise sine-wave is disturbed by a random noise, the intensity of which controls a parameter ra.
Results of such runs are presented in the upper figure. The function sinide does not need any guess of parameter values, and is very fast and stable. It needs the function 'extr' from FEX at www.mathworks.com/matlabcentral/fileexchange/10272, and the function LMFnlsq from www.mathworks.com/matlabcentral/fileexchange/17534 to perform nonlinear least squares fit after a thorough initial parameter estimation from the given vectors of samples of the dependent variable, a dependent (measured) variable and sampling frequency. The solution shows how good is the identification from a strongly noisy data.
The demo program sinidetest exploids other functions from FEX, what is described in a help part of the program. No optimization Toolbox is required.

Cite As

Miroslav Balda (2024). SINIDE - Parameter identification of a sine-wave from a measured signal (https://www.mathworks.com/matlabcentral/fileexchange/45567-sinide-parameter-identification-of-a-sine-wave-from-a-measured-signal), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Linear Model Identification in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.7.0.0

The errors found by Dan and repaired by Werner are removed now.

1.6.0.0

Chnages in function sinide served for better description. Function driver sinidetest has been much improved in its ability to process data takem from arbitrary kinds of files.

1.5.0.0

Improved description of requirements (function extr.m for finding all extremes).

1.4.0.0

Replaced initial figure of this leave.

1.3.0.0

Replaced initial figure of this leave.

1.2.0.0

The algorithm of the function has been improved in the part of estimating initial guess of parameters.

1.1.0.0

There were modified outputs of the function and the testing script, and repaired description of the function.

1.0.0.0