Optimize a variable in a function to match experimental data

I have a set of experimental data in excel, and I am trying to match that data to a theoretical function, which has a variable that needs to be optimized. If I were doing it in Excel, I would find the sum of squared errors and use solver to optimize that variable. How would I do the same thing but via Matlab?

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 20일
Also see lsqcurvefit(): https://www.mathworks.com/help/releases/R2020a/optim/ug/lsqcurvefit.html. It minimizes the sum of square errors. The following shows an example of using lsqcurvefit for a fictitious model. You can adapt it according to your model
x = 1:100;
model = @(a,b,c,x) a*x + exp(b*x) + c; % model to estimate
y = model(2,0.1,10,x) + 1000*rand(size(x)); % get response from model and add noise
x0 = rand(3,1); % initial guess for a, b, and c
est_param = lsqcurvefit(@(param, x) model(param(1), param(2), param(3), x), x0, x, y);
plot(x, y, '.', x, model(est_param(1), est_param(2), est_param(3), x))

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Conditional Mean Models에 대해 자세히 알아보기

질문:

2020년 4월 19일

답변:

2020년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by