12345678910111213
x=6*rand(1,10)+2 for i=1:10 if i<5 x(i)=-1; elseif i>=5 && i<8 x(i)=1; else x(i)=3; end end x
12345678910
i = 1; while(i != 10) { x[i] = 3; //default if(i<5) x[i] = -1; else if(i < 8) // the check on 5 is redundant, its in the else on the same check x[i] = 1; i++; }