1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| filename = 'WRHS.xls';
file= xlsread (filename);
x= file (:,1);
y= file (:,2);
lb = [ -10 -10 -10 -10]; %define the lower bound
ub =[10 10 10 10]; %define the upper bound
%options = optimset('lsqcurvefit');
options = optimset('Algorithm','levenberg-marquardt');
%options = optimset(options,'LevenbergMarquardt' ,'on');
%options = optimset(options,'Algorithm','levenberg-marquardt');
options.MaxFunEvals = 10000;
[newParameters,error] = lsqcurvefit(@myFunction, [1 1 1 1 1 1],(x-mean(x))/std(x),y,options);
figure
scatter(x,y,'.') %plot the scatter plot
hold %hold the figure
%use new parameters to get new output values
y2 = myFunction(newParameters,(x-mean(x))/std(x));
%plot the new data using the color red
plot(x,y2,'r') |