Cody

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

52.17% Correct | 47.83% Incorrect
Last solution submitted on Apr 12, 2016

Problem Comments

Solution Comments

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!

Join the 15-year community celebration.

Play games and win prizes!

Learn more