Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Multiple curve fitting with common parameters using NLINFIT

4.66667
4.7 | 3 ratings Rate this file 35 Downloads (last 30 days) File Size: 5.21 KB File ID: #40613 Version: 1.1
image thumbnail

Multiple curve fitting with common parameters using NLINFIT

by

Chen (view profile)

 

04 Mar 2013 (Updated )

Wrapper for NLINFIT which allows simultaneous fitting for multiple data sets with shared parameters.

| Watch this File

File Information
Description

This function allows you to simultaneously fit multiple data sets (for example noisy measurements) with multiple models, which share some (or all) of the fitting parameters.
Unlike difference approaches using fminsearch (or similar functions), this submission wraps around NLINFIT and thus allows immediate estimation of confidence intervals on data predictions and fitted parameters.

Required Products Statistics and Machine Learning Toolbox
MATLAB
MATLAB release MATLAB 7.14 (R2012a)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
26 May 2016 adi

adi (view profile)

great job! easy to use and well documented.

20 Apr 2016 Chen

Chen (view profile)

Trine, thanks for your comment. I have updated the function to allow a weights function/vector to be specified, and also the default functionality is now to give equal weights to all data sets.

Comment only
19 Apr 2016 Trine Freiesleben

Dear Chen. Thank you for this file. It works fine for me. Although I have a problem since I want to weight the fitting to errors on the datasets. And I got the error 'Too many input argument using nlinmultifit' when I try to make a w_cell. Do you have a solution for this?

Comment only
20 Nov 2014 Luis Cerdan

Dear Chen: To make it work, even with the example your provided, I had to remove the output arguments "errorparam" and "robustw", as otherwise nlinfit gave an error (Too many output arguments). Once remove the program worked fine for my needs.

Comment only
20 Nov 2014 Luis Cerdan  
19 Feb 2014 Kevin

Kevin (view profile)

 
19 Sep 2013 Chen

Chen (view profile)

You are always free to do the wrapping manually, yourself. I found that I routinely need to perform this task of multiple fitting, and was tired of writing code every time for different models, and came up with this solution. I hope it will help and save time to others as it did for me.

Comment only
19 Sep 2013 Matt J

Matt J (view profile)

OK, sorry, I didn't see that the parameters were shared.

I wonder, though, why it wouldn't be better to just manually write an mfile for the combined modelfun, instead of auto-wrapping several separate anonymous model functions into one big anonymous function?

You obviously don't intend this for wrapping a large number of model functions and data sets. The nesting of many anonymous functions would make it very slow. Conversely, for a small number of data sets, manually wrapping the problems together should be pretty easy.

Comment only
19 Sep 2013 Chen

Chen (view profile)

Matt: I don't understand how a for-loop would enable you to fit multiple data sets with COMMON estimation parameters.

Comment only
19 Sep 2013 Matt J

Matt J (view profile)

I would be surprised if this were faster than a for-loop. If I'm wrong, it might be worthwhile to add some demo files showing the advantage of the wrapping.

Comment only
Updates
20 Apr 2016 1.1

Updated: 1) Allow use to specify a cell array of weights vectors/functions, similarly to NLINFIT itself. 2) When a weights cell array is not provided by the user, the NLINMULTIFIT will create one by itself to give equal weight to all data sets.

20 Apr 2016 1.1

Updated: 1) Allow use to specify a cell array of weights vectors/functions, similarly to NLINFIT itself. 2) When a weights cell array is not provided by the user, the NLINMULTIFIT will create one by itself to give equal weight to all data sets.

Contact us