Hello, I'm new to Matlab. I would like to fit two parameters used in differential equations by using lsqnonlin. The idea is to find the parameters by minimising the difference between the experimental curve and the generated curve. I tried to minimize the ssq between the two curves but if you look at the graphs it seems that Matlab somehow takes a wrong average of the difference between the two curves.
The code (one function and one script)looks like this:
function [r,y] = kin4( k)
[t,y] = ode23s(@kin2,[300/n:300/n:300],[0.1,0.0]);
dy = zeros(2,1);
dy(1) = -k(1)*y(1);
dy(2) = k(1)*y(1)-k(2)*y(2);