Cody

Problem 42646. Matrix FUN

Solution 2635021

Submitted on 30 Jun 2020 by Ramesh Kumar V
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 4; y_correct = 0; assert(isequal(mat_fun(x),y_correct))

i = logical 0

2   Pass
x = [3 2 3 2 5 6 2 1 2]; y_correct = 3; assert(isequal(mat_fun(x),y_correct))

i = 9×1 logical array 1 0 1 0 0 1 0 0 0

3   Pass
x = [999 999 999 2 15 6]; y_correct = 5; assert(isequal(mat_fun(x),y_correct))

i = 6×1 logical array 1 1 1 0 1 1

4   Pass
x = 3:3:999; y_correct = 333; assert(isequal(mat_fun(x),y_correct))

i = 333×1 logical array 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

5   Pass
x = [1 2 3 4 5 6;6 5 4 3 2 1]; y_correct = 4; assert(isequal(mat_fun(x),y_correct))

i = 12×1 logical array 0 1 0 0 1 0 0 1 0 0 1 0

6   Pass
x = [7 8 11 13 14 17]; y_correct = 0; assert(isequal(mat_fun(x),y_correct))

i = 6×1 logical array 0 0 0 0 0 0

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!