Cody

Problem 73. Replace NaNs with the number that appears to its left in the row.

Replace NaNs with the number that appears to its left in the row.

If there are more than one consecutive NaNs, they should all be replaced by the first non-NaN value to the immediate left of the left-most NaN. If the NaN is in the first column, default to zero.

For example, if

x = [NaN  1   2  NaN NaN 17  3  -4 NaN]

then

y = [ 0   1   2   2   2  17  3  -4  -4]

Solution Stats

50.82% Correct | 49.18% Incorrect
Last solution submitted on Oct 18, 2017

Problem Comments

Solution Comments

Tags

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!