Skip to content
← All questions

How can I force my curve fit to respect physical limits using MATLAB?

You can force your curve fit to respect physical limits by formulating it as a constrained optimization problem using the Optimization Toolbox. Define the model coefficients as optimization variables and assign specific lower and upper bounds to each coefficient. This restricts the solver to physically meaningful regions, preventing impossible predictions like negative power or infinite output.

Conditions

  • Requires an optimization solver like lsqnonlin.
  • Objective function must be defined based on the model equation (e.g., minimizing sum of squared errors).
  • Physical or mathematical constraints on coefficients are known.

Reasoning, step by step

  1. Open the Optimization Toolbox in MATLAB.
  2. Define the model coefficients as optimization variables.
  3. Set lower and upper bounds for each variable based on physical limits.
  4. Define the objective function as the sum of squared errors between data and model predictions.
  5. Select a solver (e.g., lsqnonlin) to minimize the objective subject to the bounds.
  6. Run the optimization to obtain the constrained curve fit.

Example

The speaker explains adding bounds and constraints using the Optimization Toolbox to create a more precise model reflecting physical limitations. The MATLAB Live Editor shows an 'Optimize' task with variables x1 to x6, lower and upper bounds, and an objective function defined as sum((clean_turbine_data.power - (x1 ./ (1+exp⁡1 + \exp (-x2 * clean_turbine_da...)))^2).

Common misconceptions

  • Assuming standard curve fitting automatically respects physical constraints without explicit bounds.
  • Believing that constrained optimization always yields a worse fit than unconstrained fitting, whereas it often improves robustness.

Watch the explanation

Connected concepts

Explore next

Related questions

Understand why

↗
Meet the concept

↗
Understand why

↗
Meet the concept

↗
Find a method

↗

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.