The global CVX solver selection cannot be changed while a model is being constructed

The following error message occurs when I use the cvx_solver command to change the default CVX solver, and get an error in my CVX code, and then try and run my code again after having made changes to the code (even if the code has subsequently been fixed of all errors):

The global CVX solver selection cannot be changed while a model is being constructed.

The only way to stop this error from appearing is to comment out the cvx_solver line or exit and then restart MATLAB, which is very frustrating when you are initially creating the code for your program since you’re bound to have many errors along the way. Is there a possible fix to this issue?

Doing clear all should be far less severe than having restart MATLAB…