please help me in matlab why the following code is error
t=-10:0.1:10;
T0=1;
V=1;
x=V*square(t);
w0=2*pi/T0;
index=0;
for k=1:2:5
index=index+4*V/(k*pi)*cos(k*w0*t/2/pi-pi/2);
end
plot(t,x,t,index,'linewidth',3)
legend('original signal','approximation')
axis([-4 4 -3 3])
er=abs(x-index);
figure
plot(t,er,'linewidth',3)
legend('error')
axis([-4 4 -3 3])
it just gives me ::
Error in ==> Untitled at 5
x=V*square(t);
??? Error: File: Un8d3.m Line: 1 Column: 12
Unexpected MATLAB expression.
Isn't there a MATLAB forum - this is c++ :/ ?
The problem is that square is not defined.