# Find optimal parameter values for model

5 views (last 30 days)
Tycho Maas on 27 May 2022
Answered: Saarthak Gupta on 15 Dec 2023
I am currently modelling a heart. The current model is not ideal yet, so I need to find the optimal parameter values in order to match my wanted output. E.g. I need to model my blood pressure, which is affected by 6 parameters. The wanted output, an average over a time period, should be within the range 110-120 (mmHg). I've tried to use nested for loops of ranges, however I would like a tidier approach. Does anybody have an idea on how to approach this?
Sam Chak on 28 May 2022
So, you want to mathematically model your heart's pumping cycle: systole/diastole. If you would like to have a tidier model, then we need to see how less tidy your model is. This helps to identify the parts that need to be cleaned up.

Saarthak Gupta on 15 Dec 2023
Hi Tycho,
As per Sam’s suggestion, it would be beneficial if you could share your current model so that contributors can assess and provide an alternate approach, as per your request.
As per the title, however, I assume you simply wish to estimate the parameters of your model. This qualifies as a typical curve-fitting or regression problem, and MATLAB offers several tools and solvers for the same. Depending on the nature of the problem and existence of constraints (bound constraints and other), you may specify the optimization algorithm or let the solver makes that choice, to achieve the best fit.
Nonlinear least-squares problems typically use one of the following algorithms: Trust Region reflective, Interior point, Levenberg Marquardt, IRLS.
Whereas linear least-squares problems use one of the following: Interior point, Trust Region reflective, Active set and QR Decomposition.
Optimization Toolbox
Optimization Toolbox offers the “lsqlin” solver for linear least-squares problems and “lsqcurvefit” and “lsqnonlin” solvers for nonlinear least-squares problems.
Curve Fitting Toolbox
In the Curve Fitting Toolbox, “fit” function with the options specified in a “fitoptions” object is the standard way to fit curves and surfaces to data.
If your model belongs to one of the several library models defined as part of the toolbox, you may choose them for faster convergence (since their starting points are optimized)
Statistics and Machine Learning Toolbox
Statistics and Machine Learning Toolbox offers solvers for Linear and Nonlinear regression. “fitlm” is used for Linear regression, and “fitnlm”, “nlinfit” are used for Nonlinear regression.
Fitting a dynamic model, however, is more involved. Please refer to the following answer for a detailed discussion with an example: https://www.mathworks.com/matlabcentral/answers/43439
Please refer to the following MATLAB documentation for further reference:
Curve Fitting Toolbox
Optimization Toolbox
Statistics and Machine Learning Toolbox
Hope this helps!
Best regards,
Saarthak