How to add constraints to an existing optimization function?

1 view (last 30 days)
I have measured y values ( y_meas) at different x values ( x1,x2 ). The relationship between x1,x2 and y_meas is described with a physical law. The law needs 4 additional parameters (vParam).
Physical Law: vParam(1)*sinh(vParam(4)*x2)^vParam(3)*exp(-vParam(2)/(x1*R))
I set up a function to find the these parameters.
function y=fct(vParam,x1,x2,y_meas)
% Parameters, x values, y result values
R=8.314;
y=0;
for i=1:length(x1)
y=y+(y_meas(i)-(vParam(1)*sinh(vParam(4).*x2(i)).^vParam(3).*exp(-vParam(2).*x1(i).^-1*R^-1))).^2;
end
By now, this optimization works. But the result depends strongly on the initial values of vParam which leads to non-physical solutions. As a consequence, I want to define constraints for vParam. Unfortunately I have no idea how to do that.
Can anyone help me? Thanks in advance!
  2 Comments
Torsten
Torsten on 27 Jul 2015
What solver do you use at the moment ?
What kind of constraints do you want to define ?
In lsqcurvefit, you can introduce bound constraints on the parameters.
In fmincon, you can introduce more general constraints.
Best wishes
Torsten.

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with Optimization 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!