Fitting of one set of data to another

11 views (last 30 days)
Crosshash
Crosshash on 3 Feb 2015
Commented: Star Strider on 3 Feb 2015
I have some experimental data measured and I have a theoretical calculation to fit to the data.
How do I fit the theoretical model to the experimental data? If I try and read about MATLAB fitting, it's all about fitting functions to data - what if want to fit an already calculated model to data?
just to add, both data sets have been interpolated to share the same x axis - which is what allows me to do this when I use software such as Originpro
Thank you

Answers (2)

Star Strider
Star Strider on 3 Feb 2015
Your model is the function you want to fit to your data (this is know as parameter estimation). There are several ways to do this in MATLAB. If you have the Statistics Toolbox, use the nlinfit function (and its friends, to get related statistics), if you have the Optimization Toolbox, use lsqcurvefit, and if you have none of these, you can use fminsearch, with an extra line to define your cost function, to do the parameter estimation.
  8 Comments
Crosshash
Crosshash on 3 Feb 2015
Thank you Star Strider. Those are exactly what I'm after.

Sign in to comment.


Image Analyst
Image Analyst on 3 Feb 2015
If you want to fit the data to a polynomial, such as a line, you can use polyfit() and polyval() functions. I've attached a demo for you to look at and run.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!