关于matlab行向量设置

matlab由于向量问题输出不了

function[t] =sf(a,b)

t=zeros(1,100);
for x=linspace(-1e-3,1e-3,101)
if -(a+b)/2<=x<=-(b-a)/2
t=1;
else if (b-a)/2<=x<=(b+a)/2
t=1;
else
t=0;
end
end

plot(x,t,'r')
end

运行结果为空图
尝试过设置t为行向量,但是设置失败
想要输出图片

子函数和主体运行程序要分开!

img

img

img