Hands-on-Interpolation and Curve Fitting with MATLAB I

  1. For the given data points;

    \begin{displaymath}
\begin{array}{rr}
x & y  \hline
2 & 2.12 \\
4 & 2.24 \\
6 & 2.68 \\
10 & 3.56 \\
\end{array}\end{displaymath}

  2. For the given data points;

    \begin{displaymath}
\begin{array}{rr}
x & Y  \hline
1 & 1.3\\
2 & 3.5\\
3 & ...
...\\
7 & 10.1\\
8 & 12.5\\
9 & 13.0\\
10& 15.6\\
\end{array}\end{displaymath}

    i
    Plot it (such as plot(x,Y,'o')).
    ii
    The graph suggest a linear relationship.

    $\displaystyle y=ax + b
$

    values for the parameters, $ a$ and $ b$, can be obtained from the plot.
    iii
    Write a MATLAB code that calculates each summation;

    \begin{displaymath}
\begin{array}{ccc}
\sum x_i^2 & \sum x_i & \sum x_iY_i\\
\sum x_i & N & \sum Y_i\\
\end{array}\end{displaymath}

    All the summations are from $ i= 1$ to $ i= N$.
    iv
    Then it is obtained as

    \begin{displaymath}
\begin{array}{rl}
a\sum x_i^2+b\sum x_i & =\sum x_iY_i\\
a\sum x_i+bN & =\sum Y_i\\
\end{array}\end{displaymath}

    Solving these equations simultaneously gives the values for slope and intercept $ a$ and $ b$. Now, we have a function in the form;

    $\displaystyle y=ax + b
$

    v
    Plot them (such as plot(x,y,x,Y,'o')).
Cem Ozdogan 2011-12-27