How to write indicator function in matlab
问题 I am a new user of matlab and I want to tackle the following problem: I want to construct a piecewise constant function f . f should be an anonymous function like f=@(t)1[0,0.25)(t) . However, the number of intervals for the piecewise constant function is not fixed in general. Instead, the piecewise interval depends on users input. For example, if one enters 4, the piecewise interval becomes [0,0.25), [0.25,0.5), [0.5,0.75) and [0.75,1) then f=@(t)a1*1[0,0.25)(t)+a2*[0.25,0.5)(t)+a3*1[0.5,0