t=-10:0.1:10;a=1;for i=1:2:201 { if a==1 { z(1,i)=0; z(1,i+1)=0; } else { z(1,i)=1; z(1,i+1)=1; } end a=a*(-1); } endplot(t,z)
MATLAB: I want to produce square wave without using square function, but this code it showing error, “illegal use of IF keyword”. How to rectify it
if statementsquare wave
Best Answer