Goodness of Fit Optimisation Problem
古いコメントを表示
I have a 2 parameter model which i am trying to optimise to best fit to some experimental data, but im not sure how to approach this using the optimisation app.
I have an modelling equation, which i put my parameters in and solve at each instance in time to produce modelled data. I then use a goodness of fit parameter to see how close this modelled data is to the recorded data. I would like to maximise the output of the goodness of fit parameter by changing the values of my two parameters.
I have been solving this by looping over values of the parameters and recording the goodness of fit, then finding the maximum but it is very computationally demanding. Is there a way to solve this using the optimisation application in matlab.
Thanks
回答 (1 件)
Hi,
have a read at lsqcurvefit. Forget the app - better look at the examples given, copy the code from one of them and adapt it to your problem. Least squares is the usual way of fitting curves to data- thats what this function is made for.
If you have trouble by doing so, come back with the details of your problem and the code so far. Your will get help.
This example demonstrates how to:
% Make some data with noise to the function 3*e^(x/10)
% You dont need to do this, since you have data
xdata = -5:0.1:5;
ydata = 3*exp(xdata/10);
noise = 2*(rand(1,numel(xdata))-0.5);
ydata_noisy = ydata;
% Start here
% calculate the coefficients
fun = @(x,xdata) x(1)*exp(xdata/(x(2)));
x0 = [1 1];
[x,resnorm,residual] = lsqcurvefit(fun,x0,xdata,ydata_noisy);
% calculate the results of the fitted curve
y_calc = x(1).*exp(xdata./(x(2)));
% plot results
scatter(xdata,ydata,'xb')
hold on
scatter(xdata,(ydata+noise),'og')
plot(xdata, y_calc,'r')
legend('Original Function 3*exp(x/10)','Data Points with noise', 'Fitted Function','Location','Northwest')
Best regards
Stephan
カテゴリ
ヘルプ センター および File Exchange で Fit Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!