Error: No CVX model exists in this scope


I recently run into an interesting problem while using CVX.
My CVX model gives the following output:

Status: Solved
Optimal value (cvx_optval): -0.456998
Error using cvx_end (line 13)
No CVX model exists in this scope.

Error in demo3 (line 179)

Why it is giving error like this?

Do you have an extra cvx_end after the first cvx_end ?

Yes kind of have it, I just solved the error. I had an cvx_end in a for loop, which was creating the error.
Thanks Mark.