x=[0,1,0,2,0,3,0,4]; for k=1:8 if x(k)==0 x(k)=k; else x(k)=2*k+1; end end disp(x)