I have a system of differential equations with some unknown parameters and I need to find the optimal parameter set that fits best with the data I have.For each parameter set choice (using for loops), my code solves the system of DE numerically, then extracts from the time vector a time subvector that agrees with data time values. The next step requires to extract a new output subvector for each of the variables that match with the time subvector (in order to compute the error).Here is how my code is looking:OO=[];y2=(y(:,2))';t1=t';FF=[];y1=(y(:,1))';global parameters and other global variablesfor parameter_1    for parameter_2        [t,y]=ode45('system',[time interval], [initial conditions]);        time; % time is a code that extracts the time subvector        for i=1:length(time)            for j=1:length(t1)                if time(i)==t1(j);                    FF(end+1) = y1(j);                end            end        end        for k=1:length(time)            for m=1:length(t1)                if time(k)==t1(m);                    OO(end+1) = y2(m);                end            end        end    endendAt this point the code is not over, but I would be expecting it to return the OO vector and the FF vector for the last parameter set choice of the loop. However when the code runs (without any errors) it produces  vectors OO and FF that are longer than vector time: length(time) < {length(OO),length(FF)}.
Curve Fitting problem MATLAB
matlab;curve fitting