a = 0; b = 1800; r1 = round((b-a).*rand() + a); b=b-r1; r2 = round((b-a).*rand() + a); b=b-r2; r3 = 1800-(r1+r2); r1 r2 r3 sum=r1+r2+r3