MATLAB Answers


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

Asked by Mohammed Sayan on 28 Jun 2013

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.



No products are associated with this question.

1 Answer

Answer by Roger Stafford
on 28 Jun 2013
 Accepted answer

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



but I want the lines f(x)=-x disconnected.

Is is possible?

Are you referring to doing a plot of this function? If you don't want a line connecting the points where a discontinuity occurs, you should use the '.' plotting option rather than '-'. Your plot will then be a series of dots. If you don't want dots, you will have to plot each 2*pi interval separately using the "hold on" instruction between the intervals.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!