Correlate or fit a plot through points

34 Views Asked by At

I have some points and i want to fit or correlate the best curve through them.

How can i do that?

For example i have attached sample data...

https://ufile.io/753a6

I want to fit with MATLAB or EXCEL....

Please help me:

It's only a sample data that i have generated...I want to fit or correlate at any conditions and for arbitrary data

Is kernel smoothing can help me? if yes how? I can't do that

Thanks

2

There are 2 best solutions below

0
On

Looking at your data

The data

(Large version)

it seems that it fits $$ F(t) = g(t) \sin(2\pi f t + \phi_0) $$ so the unknowns are the envelope function $g(t)$, the frequency $f$ and the initial angle $\phi_0$.

It even looks that $g(t)$ is linear: $$ g(t) = m t + n $$

An objective function to minimize could be $$ h(m, n, f, \phi_0) = \sum_{k=1}^N \left( (m t_k + n) \sin(2\pi f t_k + \phi_0)-F_k \right)^2 $$ where the $(t_k, F_k)$ are the data points.

0
On

Starting from mvw's answer and observations, I think that the curve fit could be done quite easily.

Using the proposed model $$F(t) = (mt+n) \sin(2\pi f t + \phi_0)$$ expanding the sine function as $$\sin(2\pi f t + \phi_0)=a \sin(2\pi f t)+b\cos(2\pi f t) $$ consider the problem for a given value of $f$ and, for this value, define $s=\sin(2\pi f t)$ and $c=\cos(2\pi f t)$. This makes the model to be $$F(t)=a ns+ bnc+am ts+bmtc=As+B c+C ts+D tc$$ Then, for fixed value of $f$, we can get parameters $A,B,C,D$ using a simple multilinear regression and get the corresponding sum of squares (SSQ).

Now, run the problem for different values of $f$ and plot the function $SSQ(f)$ as a function of $f$ and look for a place where it goes through a minimum value. For this point, you have the corresponding $A,B,C,D$ from which you can deduce $a,b,m,n$ and, from $a,b$ you can deduce $\phi_0$.

At this point, you have all elements to start the nonlinear regression with good and consistent estimates of all parameters.