求x1(t)
T=2;
t=T:-1:-T;
u=t>0;
y=zeros(1:T);
for k=1:T
y(k)=sum(u(k:k+T))-1;
end
plot(y) %第3部分
hold on
T=2;
t=-T:T;
u=t>0;
y=zeros(1:T);
for k=1:T
y(k)=sum(u(k:k+T));
end
x1=-2:-1
plot(x1,y) %第1部分
hold on
T=1;
t=-T:0.00001:T;
y=(t>=-1&t=-1;
u2=t>=1;
y=cos(x).*(u1-u2);
plot(t,y)