You haven't attached any file.
Yes, you can use loops, but you have to add the constraints to a constraint list
myconstraints = 
myconstraints = [myconstraints, sum(sum(M(:,:,i)))==1];
You retrieve the solution using the DOUBLE operator
SEE shows you the internal representation of the objects, not useful for you
I recommend you to work through at least the first 2 tutorials on the Wiki