Cody

Problem 42761. Fill the matrix - 1

Solution 2194805

Submitted on 6 Apr 2020
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   Fail
x = [1:8]'; n = 4; y_correct = [ 0 0 0 0 1 1 0 0 0 2 3 1 0 0 3 7 3 1 0 4 15 7 3 1 5 31 15 7 3 6 62 31 15 7 7 122 62 31 15 8 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

s = 115 62 31 15 8

Output argument "y" (and maybe others) not assigned during call to "fillMatrix". Error in Test1 (line 14) y = fillMatrix(x,n)

2   Fail
x = [1.584;-1.015;8.4587;6.0147;9.0258;-10.4785]; n = 4; y_correct = [ 0 0 0 0 1.584 1.584 0 0 0 -1.015 0.569 1.584 0 0 8.4587 10.6117 0.569 1.584 0 6.0147 18.7794 10.6117 0.569 1.584 9.0258 40.5699 18.7794 10.6117 0.569 -10.4785 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

s = 40.5699 18.7794 10.6117 0.5690 -10.4785

Output argument "y" (and maybe others) not assigned during call to "fillMatrix". Error in Test2 (line 12) y = fillMatrix(x,n)

3   Fail
x = [-2:10]'; n = 3; y_correct = [ 0 0 0 -2 -2 0 0 -1 -3 -2 0 0 -5 -3 -2 1 -9 -5 -3 2 -15 -9 -5 3 -26 -15 -9 4 -46 -26 -15 5 -82 -46 -26 6 -148 -82 -46 7 -269 -148 -82 8 -491 -269 -148 9 -899 -491 -269 10 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

s = 17 8 10

Output argument "y" (and maybe others) not assigned during call to "fillMatrix". Error in Test3 (line 19) y = fillMatrix(x,n)

4   Fail
x = [-2:10]'; n = 0; y_correct = x; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

Array indices must be positive integers or logical values. Error in fillMatrix (line 10) s(end-j:end-1)=[]; Error in Test4 (line 5) y = fillMatrix(x,n)

5   Fail
x = [0.814723686393179;0.905791937075619;0.126986816293506;0.913375856139019;0.632359246225410;0.0975404049994095;0.278498218867048;0.546881519204984;0.957506835434298;0.964888535199277]; n = 8; y_correct = [0 0 0 0 0 0 0 0 0.814723686393179;0.814723686393179 0 0 0 0 0 0 0 0.905791937075619;1.72051562346880 0.814723686393179 0 0 0 0 0 0 0.126986816293506;2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0 0 0.913375856139019;6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0 0.632359246225410;11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0.0975404049994095;23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0.278498218867048;46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0.546881519204984;94.0163513583640 46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0.957506835434298;188.443328032957 94.0163513583640 46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.964888535199277]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

s = 188.4433 94.0164 46.8740 23.3465 11.9407 6.1108 2.6622 1.7205 0.9649

Output argument "y" (and maybe others) not assigned during call to "fillMatrix". Error in Test5 (line 5) y = fillMatrix(x,n)

Suggested Problems

More from this Author62

Community Treasure Hunt

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

Start Hunting!