data = [0 5.8955; 0.1000 3.5639; 0.2000 2.5173; 0.3000 1.9790; 0.4000 1.8990; 0.5000 1.3938; 0.6000 1.1359; 0.7000 1.0096; 0.8000 1.0343; 0.9000 0.8435; 1.0000 0.6856; 1.1000 0.6100; 1.2000 0.5392; 1.3000 0.3946; 1.4000 0.3903; 1.5000 0.5474; 1.6000 0.3459; 1.7000 0.1370; 1.8000 0.2211; 1.9000 0.1704; 2.0000 0.2636]; %init_theta = [0 0 0 0]; %theta = fminsearch('fun_e1', init_theta, [], data); %x = data(:, 1); %y = data(:, 2); %estimated_y = theta(1)*exp(theta(3)*x)+theta(2)*exp(theta(4)*x); %plot(x, y, 'ro', x, estimated_y, 'b-'); %legend('Sample data', 'Regression curve'); init_lambda = [0 0]; lambda = fminsearch('fun_e2', init_lambda, [], data); x = data(:, 1); y = data(:, 2); A = [exp(lambda(1)*x) exp(lambda(2)*x)]; a = A\y; estimated_y = a(1)*exp(lambda(1)*x)+a(2)*exp(lambda(2)*x); plot(x, y, 'ro', x, estimated_y, 'b-'); legend('Sample data', 'Regression curve');