Cody

Problem 1632. Calculating Sign Changes in a Row Vector(No Element Is Zero)?

For a row vector V=[7 1 2 -3] has one sign change from 2 to -3. So N=Sign_Changes(V) must return N=1;

 V=[5 9 -2 7]; 

has two sign changes one from 9 to -2 and second -2 to 7, Thus N=2;

Similarly

 V=[-4 -6 -7 -5 -6] and V=[3 7 6 5 6 7 8 7 6] 

has no sign changes.

Solution Stats

72.0% Correct | 28.0% Incorrect
Last solution submitted on Mar 05, 2016
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