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

Learn moreOpportunities for recent engineering grads.

Apply TodayWhen 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.

23 correct solutions
21 incorrect solutions

Last solution submitted on Oct 28, 2014

1 player likes this problem

1 Comment

Jan Orwat
on 9 Jun 2014

ugly.

1 Comment

J.R.! Menzinger
on 21 Nov 2013

Very ['ni' 'ce'] HAHAHA

2 Comments