MATLAB: How to make function f(x)=-x periodic of (2*pi) explicitly

f(x)=-xperiodic functionrepeating a line function of period 2pi

Hi Folks,
I have a function f(x)=-x that starts from [-pi:pi] and I wanna repeat this function for a few periods of (2*pi) with the amplitude ranged between [pi to -pi].
I appreciate your response.

Best Answer

f(x) = mod(-x+pi,2*pi)-pi;