Using fminsearch together with fsolve to minimize a function

preview_player
Показать описание
In this screencast, we repeat example 12.1, but this time using fminsearch to find the minimum of -phi, rather than fzero to find the zero of the derivative of phi.
Рекомендации по теме
Комментарии
Автор

Hey, this is out of some minor desperation, but I have a similar problem. So my fminsearch uses initial guesses in a k matrix to call on a function2 that gives a value for error which i wish to minimise. However, function2 uses fsolve, which calls to a third script, function3, which needs to solve for temp and x (i called this var(1X2matrix)). the problem is, in function3, it won't recognise the k values within it. it says not enough input arguments when I put k in the brackets in the function name bit at the top. i.e. the guesses for k do not propogate through to the third script (I think). I've even tried assigning k to an intermediate global variable which can be shared across function2 and function3, but for some reason, the variables wipes in function3 - i know this because i've run the code step by step.

Thedarkknight