How to solve the error of: Cannot perform the operation: {invalid} .* {convex}

I wrote a convex problem, using Taylor expansion, by iterating through the loop, the first few times it works fine to get the optimal result, but after changing the threshold, the first few times it works fine, but later in the loop it comes up with Cannot perform the operation: {invalid} . * {convex}.

On one of the iterations, CVX failed to solve the problem, so the variable values returned by CVX were NaN. You then used these values in the next iteration; therefore, there were NaN in a CVX expression, which CVX does not allow. I suggest you follow my previously provided advice to use an existing non-convex optimizer rather than trying to develop your own crude optimizer, which as you can see, doesn’t work very well.