f(x)= 1表示-0.5 <x <0.5否则=“”0,=“”need =“”to =“”define =“”this =“”function =“”and =“”plot =“” =“”function =“”in =“”matlab =“”

时间:2015-07-05 11:05:29

标签: matlab

=“”
 f(x) = 1 for -0.5< X <0.5 
         otherwise 0. 


我想定义这个函数,并在-10到10的区间内在MATLAB中绘制函数。

1 个答案:

答案 0 :(得分:2)

这个怎么样

x = linspace(-10, 10, 1000);
fx = ( x > -0.5 ) & ( x < 0.5 );
figure;
plot( x, fx );