Translating from MATLAB to Simulink

I have already written a MATLAB function and script to solve a large system of differential and alegraic equations. The original model uses ode15s to solve the stiff system of algebraic and differential equations. The equations also have several constants that are brought in to MATLAB from an Excel spreadsheet. I am now wanting to somehow incorporate this into Simulink so that I can do some parameter estimation/calibration. I have zero experience with Simulink. Is this the best method for performing parameter estimation? How do I go about "translating" my model as it currenlty exists to be run in Simulink for this purpose?

댓글 수: 5

Torsten
Torsten 2026년 5월 19일
If you have modelled your process in MATLAB by the system of differential and algebraic equations and you want to estimate parameters of this model against measurement data, you don't need Simulink. You can use MATLAB optimization functions, e.g. lsqcurvefit, for this.
Or do you want to extend your model by some physical blocks available in Simulink ?
Matthew
Matthew 2026년 5월 20일
I am a little lost on how to use lsqcurvefit.
I have a model that has many (> 100) parameters. I only am concerned with calibrating a select few of those parameters to make the model results match the experimental results. The experimental results are just summary, mean datapoints of some critical measurements. How do I go about using lsqcurvefit for something like this? I only had gone the Simulink route because every time I search about parameter estimation in MATLAB, the resources always point to Simulink.
Walter Roberson
Walter Roberson 2026년 5월 20일
Do I understand correctly that you have a nonllnear model that has over 100 parameters, and each of them are unknown? Or are most of the parameters fixed in value and only a few are unknown?
Because if most of them are unknown, it is quite likely tthat lsqcurvefit will find misleading solutions. It is most common for nonlinear models to be quite sensitive to initial conditions.
For example something a simple as the sum of two phased guassians takes a lot of hunting around and frequently returns incorrect answers.
Matthew
Matthew 2026년 5월 20일
The majority are either well known or do not impart much sensitivity to the model outcomes. I am only needing to estimate/calibrate no more than 10 of the parameters.
Harald
Harald 2026년 5월 25일
Chiming in late...
You may find the problem-based approach easier to use than putting things into the format lsqcurvefit expects.
To get started with the problem-based approach: https://matlabacademy.mathworks.com/details/optimization-onramp/optim
Best wishes,
Harald

댓글을 달려면 로그인하십시오.

답변 (1개)

Ritika Thusoo
Ritika Thusoo 2026년 6월 12일 11:02

0 개 추천

Based on your description, since you already have a MATLAB implementation that uses ode15s for a stiff differential-algebraic system, it is not strictly necessary to move to Simulink for parameter estimation. You can perform parameter estimation directly in MATLAB by defining a cost function using commands such as lsqnonlin or fmincon to compare your simulation outputs with measured data.
If you prefer to use Simulink, for example, to leverage the Parameter Estimator app or to build a more extensible simulation framework, you can use a gradual approach rather than rewriting the model from scratch:
  1. Refactor your MATLAB code into functions
  • Separate the model equations, parameter inputs, and data loading, such as Excel constants.
  • Ensure the simulation can be run via a function call with parameters as inputs.
  1. Reuse your MATLAB model inside Simulink
  • Use a MATLAB Function block to integrate your existing code into a Simulink model instead of rebuilding the equations graphically.
  • This allows you to validate that the Simulink results match your current MATLAB results before proceeding further.
  1. Set up parameter estimation in Simulink
  • Use the Parameter Estimator app to import measured data, select parameters, and run optimization.
  • The tool formulates estimation as an optimization problem and allows bounds, constraints, and multi-experiment data handling.
For more information on parameter estimation, refer to the following MathWorks documentation:

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

제품

릴리스

R2026a

질문:

2026년 5월 19일

답변:

2026년 6월 12일 11:02

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by