Problem 2010. Wrap a vector, but insert NaN's at the wrap-positions.

When you plot a line that wraps, and do not want the sawtooth shape to show up in the plot, you can either draw all separate lines, or you can insert NaN's between the segments. The plot command does not draw a line between NaN's.
This assignment is to create a function that wraps a vector, and inserts NaN's where it wraps.
The modulo of the wrapping range is explicitly entered into the function.
For example, if we wrap a vector [1:20] at 3, this will result in [1 2 nan 0 1 2 nan 0 1 2 nan 0 1 2 nan 0 1 2 nan 0 1 2 nan 0 1 2].
As (almost) always, regexp and eval are not appreciated.

Solution Stats

38.82% Correct | 61.18% Incorrect
Last Solution submitted on Mar 12, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers20

Suggested Problems

More from this Author31

Problem Tags

Community Treasure Hunt

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

Start Hunting!