# Frequency, amplitude, phase and mean value of sine wave 1.0

OS : Windows / Linux / Mac OS / BSD / Solaris
Script Licensing : BSD - BSD License
Created : Jan 11, 2010
Thank you for voting...

## It applies a vectorized version of 3-point formula ...

It applies a vectorized version of 3-point formula derived by application of a Z-transform for finding amplitude and frequency of a signal.
If more than two output parameters are to be determined, all of them are optimized in the least squares sense by the function LMFnlsq.
Function: x(t) = a. sin(2. pi. f. t + phi) + x_m
Calls:
frq = sinfapm(x, fs); % Get only frequaency of sine-wave
[frq, amp] = sinfapm(x, fs); % Get frequency and amplitude
[frq, amp, phi] = sinfapm(x, fs); % Get frequency, amplitude and phase
[frq, amp, phi, ave] = sinfapm(x, fs); % ditto plus mean value
The set of more than two output parameters can be found by calling
[frq, amp, phi] = sinfapm(x, fs, Name_1, Val_1, Name_2, Val_2, . . . );
[frq, amp, phi, ave] = sinfapm(x, fs, Name_1, Val_1, Name_2, Val_2, . . . );
Input arguments:
x % vector of samples
fs % sampling frequency [Hz]
Name_i % name of the i-th optional parameter for optimization
Val_i % value of the i-th optional parameter (see function LMFnlsq)
Output arguments:
frq % frequency of x [Hz]
amp % amplitude of x