4.5

4.5 | 2 ratings Rate this file 172 downloads (last 30 days) File Size: 2.46 KB File ID: #19902

Frequency, amplitude, phase and mean value of sine wave

by Miroslav Balda

 

13 May 2008 (Updated 14 May 2008)

Code covered by BSD License  

The function sinfapm evaluates parameters of sampled sine wave

Download Now | Watch this File

File Information
Description

The function sinfap.m evaluates frequency, amplitude, phase and mean value of a uniformly sampled harmonic signal
   x(t) = a.sin(2.pi.f.t + phi) + x_m
It uses a vector version of 3-point formulae derived by application of
Z-transform (see [1]) 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.

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
phi % phase in radians
Examples:
[f,a,phi,ave] = sinfapm([1.3633;-.2428;-0.9705;1.8130;-1.9631],10);
% f = 4.0000
% a = 2.0000
% phi = 0.7500
% ave = -2.2806e-005
[f,a,phi] = sinfapm([.707,1,.707,0],20,'Xtol',1e-4);
% f = 2.5001
% a = 0.9999
% phi = 0.7853 % pi/4 = 0.785398...

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Function LMFnlsq from FEX, Id. 17534
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
31 May 2008 Ramesh Pachar  
24 Jul 2008 david sweeney

How do I get this file to run????

18 Apr 2009 Pablo

txs a lot =)).
 i need it that mean

11 Oct 2009 juho

When I implement this function for noisy sine vawes, the amplitudes seem to be very far from reality. Often, amplitudes have even minus signs(?). Any ideas why ?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
time frequency Miroslav Balda 22 Oct 2008 10:00:55
wavelets Miroslav Balda 22 Oct 2008 10:00:55
sampled sine wave Miroslav Balda 22 Oct 2008 10:00:55
wavelets Miroslav Balda 09 Nov 2008 22:33:34
sampled sine wave Jan Paskarbeit 14 Nov 2008 17:09:17
time frequency tstmwind 15 Apr 2009 13:22:15
sampled sine wave Helena P.-Blaettler 22 Apr 2009 06:50:18
sampled sine wave zxj ?y 20 Sep 2009 00:16:27
time frequency zxj ?y 20 Sep 2009 00:16:36
wavelets zxj ?y 20 Sep 2009 00:16:40
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com