- Define Output Weights: Determine the weights for each output (y1, y2, y3) based on their importance or the inverse of their variance if you are considering measurement noise.
- Create a Custom Objective Function: You will need to create a custom objective function that computes the weighted sum of squared errors between the measured outputs and the simulated outputs from the model.
- Use the Parameter Estimation Tool: Open the Parameter Estimation tool in Simulink. Import the measured data for your outputs and set up the parameters you wish to estimate.
- Specify the Custom Objective Function: In the Parameter Estimation tool, you can specify the custom objective function by selecting "New" > "Custom Objective Function" and then entering your function that computes the weighted error.
Applying weighted regression for Parameter estimation in Simulink
3 views (last 30 days)
Show older comments
Hello everybody,
I am dealing with parameter estimation in Simulink with 3 measured outputs (y1, y2, y3) that have different weights on my model. It is not rational to simply introduce all the outputs with similar impact on the fitting process. How may I use a weighted objective function in the parameter estimation process in Simulink?
I appreciate any other recommendation to have relaible parameter estimation process.
Thanks in advance.
Kourosh.
0 Comments
Answers (1)
Hornett
on 27 Sep 2024
In Simulink, when performing parameter estimation with multiple outputs that have different levels of importance or reliability, it is indeed important to use a weighted objective function. This ensures that each output is appropriately considered during the parameter estimation process according to its weight.
Here's how to use a weighted objective function in the parameter estimation process in Simulink:
Here is an example of how you might define a custom objective function in MATLAB:
function weightedError = customObjectiveFunction(params, measuredData, simOptions)
% Set the parameter values in the model
set_param('model_name', 'parameter_name1', num2str(params(1)), ...
'parameter_name2', num2str(params(2)), ...
'parameter_name3', num2str(params(3)));
% Simulate the model with the current parameter values
simOut = sim('model_name', simOptions);
% Extract the simulated outputs
y1_sim = simOut.yout.getElement('y1').Values.Data;
y2_sim = simOut.yout.getElement('y2').Values.Data;
y3_sim = simOut.yout.getElement('y3').Values.Data;
% Compute the weighted error for each output
error1 = measuredData.y1 - y1_sim;
error2 = measuredData.y2 - y2_sim;
error3 = measuredData.y3 - y3_sim;
% Define the weights for each output
weight1 = measuredData.weight1;
weight2 = measuredData.weight2;
weight3 = measuredData.weight3;
% Compute the weighted sum of squared errors
weightedError = sum(weight1 * error1.^2 + weight2 * error2.^2 + weight3 * error3.^2);
end
Replace 'model_name', 'parameter_name1', 'parameter_name2', 'parameter_name3', and the measuredData structure with the actual names and data relevant to your model.
0 Comments
See Also
Categories
Find more on Estimate Parameters and States 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!