Fminsearch in a for loop

조회 수: 1 (최근 30일)
Siân Chilcott
Siân Chilcott 2021년 4월 6일
답변: Star Strider 2021년 4월 6일
Hi there, I am trying to minimise the difference between two vectors using fminsearch. I have managed to do this using the code atttached however the variable 'beta_hold' and 'rate' in this sample code are just 1 vector from two 12x12 arrays. I need to somehow loop over the below code for every 'rate' and 'beta_hold' in the 12x12 array but I can't seem to figure out how to use a loop within multiple functions. If anyone could help with this or point me in the right direction that would be appreicated!

채택된 답변

Star Strider
Star Strider 2021년 4월 6일
The code borders on being indeciperable.
Do not use global variables. See Passing Extra Parameters for the correct way to pass information to functions.
I have no idea what you’re doing or what you want the code to do. If you want to compare individual rows or columns, see the documentation section on Matrix Indexing to understand how to select them. It is then straightforward to loop through the matrices.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by