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

Solution 314993

Submitted on 4 Sep 2013 by Alfonso Nieto-Castanon

Correct

23Size
Leading solution size is 20.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = 20;
n = 3;
y_correct = 3;
assert(isequal(nextpow(n,x),y_correct));

                    
2
Pass
 
%%
x = 16;
n = 4;
y_correct = 2;
assert(isequal(nextpow(n,x),y_correct));

                    
3
Pass
 
%%
x = 81;
n = 8;
y_correct = 3;
assert(isequal(nextpow(n,x),y_correct));

                    
4
Pass
 
%%
x = 0;
n = 1;
y_correct = 0;
assert(isequal(nextpow(n,x),y_correct));

                    
5
Pass
 
%%
x = -32;
n = 2;
y_correct = 5;
assert(isequal(nextpow(n,x),y_correct));

                    
6
Pass
 
%%
x = -100;
n = 10;
y_correct = 2;
assert(isequal(nextpow(n,x),y_correct));