Pattern Search Stopping Criteria

1 view (last 30 days)
MSA
MSA on 10 Aug 2021
Commented: MSA on 11 Aug 2021
Hi
I have been trying to implement a way to stop the pattern search algorithm, if it reaches a specific function value (or r^2 value in our case). It seems like you can't put 'break' inside the function to stop it with specified values.
Is there any particular fucntions that we can use as a stopping function?
Thanks a lot.

Accepted Answer

Sean de Wolski
Sean de Wolski on 10 Aug 2021
You can use an outputfcn for this. The output function can pass back a stop flag.
  1 Comment
MSA
MSA on 11 Aug 2021
I was able to stop using the outputfcn. Thanks for your answer and help.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 10 Aug 2021
Hard to say with out seeing the code. You can put a break inside a for loop or a while loop and it will go to the line right after the end of that loop with all the values having whatever value they had last.
If you just want to exit the entire function immediately, you can use "return" instead of break.
Post your code if you want more help.
  3 Comments
MSA
MSA on 11 Aug 2021
I am sorry for making it confusing.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!