Minimize using fminsearch?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The question is this
Use fminsearch to minimize the function you wrote above, using an initial guess of your choosing. Use the resulting c1 and c2 to evaluate f(x) at the values of x from exercise 2, storing the result as y. Plot the data and your curve (using x and y) to verify the fit. Once verified, save the first 10 elements of y
My code is:
objFunc = @(c) ( errFunc(c) );
C = fminsearch(objFunc, [1.0;1.0]);
for j=1:n
y(j) = C(1)*sin(x(j)+C(2));
end
What am i doing wrong??? i'm sure my errFunc is correct...
3 commentaires
Star Strider
le 4 Nov 2015
You need to use fminsearch to minimise the sum of squares difference between your objective function (which is a function only of your parameters and your independent variable) and your dependent variable. I usually do this with two functions, the objective function and the sum-of-squares cost function, and minimise the cost function.
Réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!