COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Model a function fitting the data

• Follow

```Hi,
I have some data which is stored as three matrices, X, Y, and Z.
I want to find a function that fits the data.
That is somthing like F(X,Y) = Z.
Does Matlab have any toolbox or function for this?
Thanks.

Rock
```
 0

```
"Rock" <by0390742001@yahoo.com.tw> wrote in message
news:ij0qi3\$1nb\$1@fred.mathworks.com...
> Hi, I have some data which is stored as three matrices, X, Y, and Z.
> I want to find a function that fits the data.
> That is somthing like F(X,Y) = Z.
> Does Matlab have any toolbox or function for this?
> Thanks.

Look at the LSQCURVEFIT function in Optimization Toolbox, the Curve Fitting
Toolbox, and/or the regression functions in Statistics Toolbox to name a
few.

This section from the documentation for MATLAB may also be of interest to
you.

http://www.mathworks.com/help/techdoc/data_analysis/f1-6010.html

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

```
 0
Reply slord (13267) 2/10/2011 2:18:09 PM

```Hi Rock

> Look at the LSQCURVEFIT function in Optimization Toolbox, the Curve
> Fitting Toolbox, and/or the regression functions in Statistics Toolbox to
> name a few.
>
> This section from the documentation for MATLAB may also be of interest to
> you.
>
> http://www.mathworks.com/help/techdoc/data_analysis/f1-6010.html

Two of the techniques that Steve recommended assume that you can specify a
specific function that best describes that relationship between your
variables.

For example, if your using regression analysis you'll need to assume that
the relationship between your variables is best modeled as a surface or a
hyperbolic paraboloid or whatever.  You can then use regression analysis to
identify a set of parameters for this surface that best explains your data
set.

In a lot of cases, this assumption isn't true.  The only thing that you have
to work with is three vectors of data.  You can't specify precisely what
type of function you should use for your regression.  The following blog
posting provides some example code showing how you can use a combination of

Localized Regression
Cross Validation
Bootstrap

to solve this type of problem

http://blogs.mathworks.com/loren/2011/01/13/data-driven-fitting/

The example that I use in the blog shows a curve fitting problem rather than
surface fitting, but its pretty easy to modify the code to turn this into a
surface fitting example...

```
 0

```Thanks both of your help!
Now, I know how to use the fitting GUI tool(sftool) to find the model.
One thing I want to mention is that I got confused when I read the Matlab document about sftool.
It says that input(X input, ..., etc) can be in the form of matrix.
If you want to import a matrix in the workspace, you can't find it in the selected list.
Finally, I figured out that the input should be in the form of vector.

Rock
```
 0
Reply by0390742001 (2) 2/15/2011 4:30:08 PM

3 Replies
367 Views

Similiar Articles:

7/26/2012 5:28:12 AM