How do I make a matrix in a specific for loop?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!