|
On Sep 30, 6:12 am, "Supreet " <supreet....@gmail.com> wrote:
> eige,
>
> I shall try FFT (i havent used it before). The thing I am interested in is getting an equation in terms of A*sin(wt+ph), where A is its amplitude, w is the frequency and ph is its phase.
>
> thx!
>
> eige <jei...@gmail.com> wrote in message <ed2be6ff-d8dc-4f16-8348-507b8d03f...@m11g2000yqf.googlegroups.com>...
> > Just use an FFT. An FFT of size data gives a least squares fit to the
> > set of complex exponentials in DFTMTX(length(data));
>
> > On Sep 9, 1:41?pm, "Supreet " <supreet....@gmail.com> wrote:
> > > Hi all,
>
> > > I wanted some advice and suggestion with regards to curve fitting to an almost sinusoidal data array.
>
> > > I am trying to do dynamic analysis of a closed loop position system. In the loop is a micro-controller that samples data (sampling time is 1 ms). It saves data for a couple of cycles and then transmits it to a computer as a text file. I have added a sample data set at the end of this post.
>
> > > I have used MATLAB to import this text file, plotted it and used the Curve Fitting Toolbox but couldnt get an equation for the sine wave.
>
> > > Can anyone suggest a better method.
>
> > > Thanks.
>
> > > a sample data looks like this:
> > > 29
> > > 29
> > > 29
> > > 28
> > > 37
> > > 44
> > > 56
> > > 67
> > > 79
> > > 83
> > > 88
> > > 96
> > > 102
> > > 112
> > > 112
> > > 112
> > > 109
> > > 102
> > > 96
> > > 88
> > > 80
> > > 71
> > > 63
> > > 55
> > > 50
> > > 45
> > > 41
> > > 38
> > > 35
> > > 33
> > > 32
> > > 31
> > > 30
> > > 30
> > > 29
> > > 38
> > > 45
> > > 55
> > > 66
> > > 76
> > > 85
> > > 93
> > > 95
> > > 100
> > > 104
> > > 113
> > > 114
> > > 108
> > > 102
> > > 95
> > > 87
> > > 79
> > > 70
> > > 62
> > > 55
> > > 49
> > > 45
> > > 40
> > > 37
> > > 34
> > > 32
> > > 31
> > > 30
> > > 29
> > > 29
> > > 29
> > > 41
> > > 47
> > > 55
> > > 67
> > > 78
> > > 86
> > > 93
> > > 100
> > > 111
> > > 111
> > > 111
> > > 110
> > > 109
Well, FFT is exactly the wrong way to go about fitting a single sine
wave to your data.
Ignore this bad advice. You will spend a lot of time and get nowhere.
Better to follow jrenfree's advice.
And if you know the frequency a priori, it becomes a linear least
squares problem that can be solved using Matlab's \ operator.
|