Fminsearch in a for loop

2 views (last 30 days)
Siân Chilcott
Siân Chilcott on 6 Apr 2021
Answered: Star Strider on 6 Apr 2021
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!

Accepted Answer

Star Strider
Star Strider on 6 Apr 2021
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.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!