I have implemented a parametric step function using object orientation and vectorization code but there is an inconstancy in some results. The code is as follows:
function Y = value(obj,X)
Y=double(((X>=0) & (X<0.3)))...
+double((X>=0.3) & (X<0.4)).*obj.eps...
+double((X>=0.4) & (X<0.6))...
+double((X>=0.6) & (X<0.7)).*obj.eps...
+double((X>=0.7) & (X<=1));
I tested the function using, eps=0.8, dx=1/20 and X=(dx:dx:1-dx). When calculating Y=value(a,X), X(12)=0.6 but Y(12)=1 when I should expect the result to be 0.8 according to the previous inequalities. Any help will be appreciated. Thanks.