MATLAB: How to create a periodic function

MATLABperiodic function

The function at [0,2] is y=x for [0,1] and y=2-x for [1,2], I want the above function repeated at [2,10], so I need a periodic funtion in the whole [0,10], who can help me code it ,thank you.

Best Answer

Not sure what you mean by "repeated at [2,10]". Maybe this:
y = mod(x,2);
ix = y > 1;
y(ix) = 2 - y(ix);