How to design a proper script/code for estimating multiple parameters (more than three) for a model, without using 'lsqnonline'?
이전 댓글 표시
Hello everyone.
I wanted to ask if there is a proper way for designing a script to estimate multiple parameters for a model.
My problem is that I have a model function - let say 'My_model(a,b,c,d)' - that needed 4 different parameters, and I want to fit the model with the measured data. I wanted to estimate the best 4 parameters that will give the least Root-Mean-Square-Error (RMSE). I have designed my codes using for loops. I would like to find a better way to design the code, and would like to ask your help, comments or suggestions on what should I do to improve it.
Below is the scripts:
% Script Example
load('Data'); %load the 'Data_measured' with size 1 x n
% Parameters to estimate
a = 0.12:0.08:4.1; %the estimated range for 'a'
b = 0.01:0.01:1; %the estimated range for 'b'
c = 0.0:0.01:1; %the estimated range for 'c'
d = 1.2:0.02:2; %the estimated range for 'd'
% Declare initial error
RMSEr = 100;
% The Estimation
for i1=1:size(a,2)
for i2=1:size(b,2)
for i3=1:size(c,2)
for i4=1:size(d,2)
Data_Predict = My_model(a(i1), b(i2), c(i3), d(i4)); % Having size 1 x n
Er = sqrt(nansum((Data_measured - Data_Predict).^2)) * 100 / (size(Data_measured,2));
if Er < RMSEr
RMSEr = Er;
a_best = a(i1);
b_best = b(i2);
c_best = c(i3);
d_best = d(i4);
end
end
end
end
end
This script takes a long time to estimates all the best parameters for the model. I would like to know if there is a more suitable way, method, and/or built-in function that can help me to improve this code.
Thank you very much.
Note: I have looked 'lsqnonline' and 'lsqcurvefit' functions, but I don't know how to use it to estimate multiple parameters, or whether it is suitable for my problem.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Robust Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!