Fitting 4 parameters with constraints
Show older comments
I am trying to fit a function to a data set in order to fit 4 parameters. I have been using lsqcurvefit because it is the only way that I know how to do a good easy fitting. But the problem is that I need to add constraints to my parameters. This is not possible using lsqcurvefit. I wonder if there is a function or a manual way of doing this.

where A1 D1 A2 D2 are unknown cosntants.
The constraints I need to have is that D1 and D2 are less than 0.001 (D1 and D2 < 0.0008). Any solution that includes either D1 or D2 greater than that is not of interest.
A solution that lsqcurvefit is finding is
A1 = 0.364
D1 = 0.001338
A2 = 0.610
D2 = 0.000110
*****Plot as a semilogY ****
D1 in this case is greater than my desired constraint. I would like for it to skip it and keep iterating.
I will include my data below if anybody could help me I appreciate it!
clear; clc; clf; close all;
D_0 = [0.5 0.00001 0.5 0.00001]; %initial guess if necessary for A1 D1 A2 D2 respectively
xdata = [9.85 32.05 66.83 114.44 174.55 247.57 333.00 431.44 542.19 666.04 802.12 951.39 1113.38 1287.47 1474.87 1674.29 1887.11 2600.14 2863.78 3139.17 3428.23 4043.41 4369.45 4709.33 5425.99 5802.67 6193.38 6595.39];
ydata = [1 0.9569 0.9528 0.8894 0.8387 0.8995 0.7911 0.773 0.7523 0.7155 0.7086 0.6478 0.6269 0.6175 0.574 0.551 0.4991 0.4559 0.4449 0.4314 0.4212 0.407 0.3856 0.3511 0.3526 0.303 0.3148 0.2912];
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!