How do I make a matrix in a specific for loop?
Mostrar comentarios más antiguos
I am using a for loop with the function "fminsearch" and want to save the data into a matrix, with each iteration of the for loop saving to the subsequent cell, rather than replacing the variable name with each iteration.
Here is the code that I have:
options = optimset();
for i=1:7
best_fit_eff(i) = fminsearch(@curvefit, [1,1], options, dose, D_eff(:,i));
end
And I get an error displaying "In an assignment A(I) = B, the number of elements in B and I must be the same."
If it take out the (i) after best_fit_eff, it would run properly, but then Matlab would only retain the best fit of the 7th iteration, but I want a matrix with the best fit values of all the iterations. Can anyone help me please?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!