如何用MATLAB生成f(t)=g(t)cos10πt的信号波形,其中g(t)为门函数

我直接写
t=-1:0.001:3;
g=2*(t>=-0.5)-(t>=0.5);
stairs(t,g);
axis([-1,1,0,3])
>> f=g*cos(10*pi*t)
出错了,为什么?

t=-1:0.001:3;
g=(t>=-0.5)-(t>=0.5); %没有2
stairs(t,g);
axis([-1,1,0,3])
f=g.*cos(10*pi*t); %点乘,即数组乘法
温馨提示:答案为网友推荐,仅供参考