How do I make a matrix in a specific for loop?
显示 更早的评论
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?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!