I would eliminate temp altogether—in fact, the temp = 0 term will eventually force an error when you reach cvx_end, for the reasons explained in Assignment and expression holders.
Then I would replace the objective term with this:
minimize (alfa.*labels)'*K_matrix*(alfa.*labels)
I think you should be able to confirm by inspection that this is correct.
Very good, but why use temp here at all? And if you insist on using temp, why not use it for both the left and right-hand sides of the quadratic form? It seems you’re simply making your code less readable for no practical reason.