fminsearch
6 次查看(过去 30 天)
显示 更早的评论
Hi, I need to find the best set of paramethers to minimize a chi-squared function. I wrote the function chi.m:
function chi = chi(theta, comp, sumcutmean);
model = theta * comp;
f = 0.0;
for i=1:1936
f = f + (sumcutmean(i) - model(i))^2;
end
chi = f;
end
where theta is 1x4 matrix of paramethers, comp is a 4x1936 matrix, of course model and sumcutmean are 1x1936. I tried to typing fminsearch in several ways, always obtaining errors. What is the correct expression to use?
0 个评论
回答(3 个)
Taniadi
2012-5-3
i think that one of your errors is writing the function. the function should use different name for output variables.
0 个评论
Taniadi
2012-5-15
I think that you can try to save your file using the filename "f.m" (equating your function name in function definition". And try to solve by using : theta = fminsearch(@f, guess,[],parameter). where parameter is list of parameters you try to include.
1 个评论
Walter Roberson
2012-5-15
Adding the parameters at the end of the fminsearch() call is not documented as a possibility. Instead, using function handles and anonymous functions is recommended.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!