Discover MakerZone

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

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!

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

Created by J-G van der Toorn

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.


Problem Group

Solution Statistics

24 correct solutions 22 incorrect solutions
Last solution submitted on Apr 12, 2016

Problem Comments

Solution Comments