How to create an analytical record for this function, using character variables and MATLAB commands:

f(x) = {x, 0<=x<=1/2; 1-x,1/2<=x<=1} 

?

    1 answer 1

    If MATLAB version 2016b or newer is available, you can use piecewise . If not, then:

     syms y(x) y(x) = heaviside(x)*heaviside(1/2-x)*x+heaviside(x-1/2)*heaviside(1-x)*(1-x)