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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Incorrect

51Size

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

This solution is outdated. To rescore this solution, log in.

Test

Code Input and Output

1

Fail

%% x = 1; y_correct = {'1'}; assert(isequal(fizzbuzz(x),y_correct))

Error: The left hand side is initialized and has an empty range of indices. However, the right hand side returned one or more results.

2

Fail

%% x = 3; y_correct = {'fizz'}; assert(isequal(fizzbuzz(x),y_correct))

Error: The left hand side is initialized and has an empty range of indices. However, the right hand side returned one or more results.

3

Fail

%% x = 5; y_correct = {'buzz'}; assert(isequal(fizzbuzz(x),y_correct))

Error: The left hand side is initialized and has an empty range of indices. However, the right hand side returned one or more results.

4

Pass

%% x = 15; y_correct = {'fizzbuzz'}; assert(isequal(fizzbuzz(x),y_correct))

ans = [15]

5

Fail

%% x = [1 3 5 15 16]; y_correct = {'1', 'fizz', 'buzz', 'fizzbuzz','16'}; assert(isequal(fizzbuzz(x),y_correct))

Error: The right hand side of this assignment has too few values to satisfy the left hand side.

6

Fail

%% x = []; y_correct = {}; assert(isequal(fizzbuzz(x),y_correct))

Error: Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [0 0].'

7

Fail

%% x = 1:100; y_correct = arrayfun(@(n)num2str(n), x, 'uniform', false); y_correct(mod(x, 3)==0) = {'fizz'}; y_correct(mod(x, 5)==0) = {'buzz'} y_correct(mod(x, 15)==0) = {'fizzbuzz'}; assert(isequal(fizzbuzz(x),y_correct))

Error: The right hand side of this assignment has too few values to satisfy the left hand side.