4.5

4.5 | 2 ratings Rate this file 24 Downloads (last 30 days) File Size: 5.05 KB File ID: #23214
image thumbnail

Four-Parameter Sinefit

by Marko Neitola

 

06 Mar 2009 (Updated 08 Sep 2011)

Least squares sinusoid fit. Optimization toolbox not needed. Data can be non-uniformly sampled.

| Watch this File

File Information
Description

Least squares sinusoid fit algorithm described in IEEE Standard for Digitizing Waveform Recorders (IEEE Std 1057): Algorithm for three-parameter and four-parameter least squares fit to sinewave data using matrix operations.

The algorithm is (in most cases) really quick. If the signal frequency is a guess, it has to be close to true frequency value.

For further information, consult IEEE Std 1057 and/or IEEE Std 1241 documentation.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Modulo Time Plot

MATLAB release MATLAB 7.6 (R2008a)
Other requirements None. Should work on older MATLAB versions.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
01 Apr 2010 Edwin

The program worked fine for me it was exactly what I was looking for. I use it for the estimation of the SINAD and subsequent ENOB value. The method tends to shift more signal to the residual when the signal that is used gets longer.

28 Sep 2010 K E

Here is an example with a regular sinusoid, which may be helpful:
t = 0:0.1:1000 ; % Time must be in seconds, not Matlab time
T = 10 ; % Period (s)
f = 1/T ; % Signal frequency (not sampling frequency!)
y = 2*sin(2*pi*t./T) ; % Sinusoid
[params, yest, yres, rmserr] = sinefit(y, t, f, 1, 1, 1) ;

16 Nov 2011 Daniel Wei

This is actually a cosine fit, I think.

Please login to add a comment or rating.
Updates
18 Mar 2009

A minor bugfix in the plotting operation: now ALL samples are included in modulo-time plots.

18 Aug 2010

A feature update: added a possibility to fit non-iteratively.

26 Aug 2011

Improved iteration convergence: the accuracy for the initial frequency guess is more relaxed.

08 Sep 2011

Fixed a bug in input parameter handling (varargin behavior).

Tag Activity for this File
Tag Applied By Date/Time
leastsquares Marko Neitola 06 Mar 2009 10:22:35
sinusoid Marko Neitola 06 Mar 2009 10:22:35
data diagnostic Marko Neitola 06 Mar 2009 10:22:35
fit Marko Neitola 06 Mar 2009 10:22:35
least squares Marko Neitola 19 Mar 2009 13:36:27
four parameter Marko Neitola 03 Nov 2009 04:51:12
sinusoid Jose Ercolino 28 Apr 2011 12:19:50
sine Jose Ercolino 28 Apr 2011 12:19:50
fit Jose Ercolino 28 Apr 2011 12:19:50
harmonic Jose Ercolino 28 Apr 2011 12:19:50
sinusoid fit Marko Neitola 26 Aug 2011 09:21:45

Contact us at files@mathworks.com