Create a for loop using fminsearch
조회 수: 4 (최근 30일)
이전 댓글 표시
I am creating a matlab code that utilizes fminsearch over a number of guesses for initial variables (3 variables total, 10 guess). I have created an array of guesses, i.e. a 10x3 matrix with each row representing one iteration (1,1 = var1, 1,2 = var2, 1,3 = var3). I have run the code with nominal values and a single iteration works, but I don't know how to incorporate the for loop with fminsearch. The objective function is elusive to me. In this particular problem, second order differential equations are solved for each set of variables, and then a corresponding statistical value is calculated for each case. When creating the objective function to use for fminsearch, should I put my for loop within the main script, or in the objective function? Additionally, since the objective function can only take one variable array, and I have recently been told it is nothing but a placeholder, should I define my variables within the objective function? An example of using a for loop with fminsearch using ode45 and how to choose the proper objective function would be very helpful. I understand that the objective function is the function I want to minimize, however the function I want to minimize (which is a statistical value sigma), depends on a number of other functions. Any help appreciated. Apologize if this is a poor description. Also, please do not suggest using the optimization toolbox, I need to solve this strictly using code. Thanks!
댓글 수: 0
답변 (2개)
Chibuzo Nnonyelu
2016년 4월 21일
If I understand your question correctly, you want to be able to run the fminsearch for each initial guess at the time time?
Well, you can use the parfor and make sure to have every variable you need inside the parfor loop.
However, parfor loop does not allow the creation of figures inside the loop.
My suggestion is that you use the optimtool and export the code after entering the details in the optimtool GUI. You can format the code as a function and run inside the parfor loop.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!