how to graph a function that is periodic piecewise with "n" cycles

 Accepted Answer

repmat() the single cycle "n" times.
Note: you need to decide whether at the end of each cycle the graph is to connect to the beginning of the next, or if instead there is to be a jump from the end of each cycle to the beginning of the next.

4 Comments

Thank you very much Walter! I really appreciate the answer, could you do me a favor and send me an example code
x = 0:49
y = sin(x);
y(x > 20) = tan(x(x>20));
y = repmat(y, 1, 10);
x = 0 : length(y) - 1;
plot(x, y)
@Walter Roberson lol, master walter, you are everywhere, ahaha. I am searching this piecewise function as well.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!