Cody

Solution 867984

Submitted on 7 Apr 2016 by James
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 = [1:8]'; n = 4; y_correct = [ 0 0 0 0 1; 0.2 0 0 0 2; 0.44 0.2 0 0 3; 0.728 0.44 0.2 0 4; 1.07360 0.728 0.44 0.2 5; 1.48832 1.07360 0.728 0.44 6; 1.945984 1.48832 1.07360 0.728 7; 2.4471808 1.945984 1.48832 1.07360 8]; y = fillMatrix2(x,n); assert(all(abs(y(:)-y_correct(:))<1e-4));

2   Pass
x = [0.9649; 0.1576; 0.9706; 0.9572; 0.4854; 0.8003; 0.1419; 0.4218; 0.9157]; n = 10; y_correct = [0 0 0 0 0 0 0 0 0 0 0.9649;0.0877 0 0 0 0 0 0 0 0 0 0.1576;0.0223 0.0877 0 0 0 0 0 0 0 0 0.9706;0.0982 0.0223 0.0877 0 0 0 0 0 0 0 0.9572;0.106 0.0982 0.0223 0.0877 0 0 0 0 0 0 0.4854;0.0727 0.106 0.0982 0.0223 0.0877 0 0 0 0 0 0.8003;0.1079 0.0727 0.106 0.0982 0.0223 0.0877 0 0 0 0 0.1419;0.0579 0.1079 0.0727 0.106 0.0982 0.0223 0.0877 0 0 0 0.4218;0.0886 0.0579 0.1079 0.0727 0.106 0.0982 0.0223 0.0877 0 0 0.9157;]; y = fillMatrix2(x,n); assert(all(abs(y(:)-y_correct(:))<1e-4));

3   Pass
x = [1:20]'; n = 0; y_correct = [1:20]'; y = fillMatrix2(x,n); assert(all(abs(y(:)-y_correct(:))<1e-4));

4   Pass
x = [0.7922;-0.9595;-0.6557;0.03570;0.8491;0.9340;0.6787;-0.7577;0.7431;0.3922;-0.6555;0.1712;0.7060;-0.03180;0.2769;-0.04620;0.09710;0.8235;-0.6948;0.3171]; n = 4; y_correct = [0 0 0 0 0.7922;0.1584 0 0 0 -0.9595;-0.1602 0.1584 0 0 -0.6557;-0.1315 -0.1602 0.1584 0 0.0357;-0.0195 -0.1315 -0.1602 0.1584 0.8491;0.1393 -0.0195 -0.1315 -0.1602 0.934;0.1524 0.1393 -0.0195 -0.1315 0.6787;0.1639 0.1524 0.1393 -0.0195 -0.7577;-0.0643 0.1639 0.1524 0.1393 0.7431;0.2269 -0.0643 0.1639 0.1524 0.3922;0.1742 0.2269 -0.0643 0.1639 -0.6555;-0.0310 0.1742 0.2269 -0.0643 0.1712;0.0954 -0.0310 0.1742 0.2269 0.706;0.2343 0.0954 -0.0310 0.1742 -0.0318;0.0882 0.2343 0.0954 -0.0310 0.2769;0.1328 0.0882 0.2343 0.0954 -0.0462;0.1009 0.1328 0.0882 0.2343 0.0971;0.1307 0.1009 0.1328 0.0882 0.8235;0.2552 0.1307 0.1009 0.1328 -0.6948;-0.0151 0.2552 0.1307 0.1009 0.3171]; y = fillMatrix2(x,n); assert(all(abs(y(:)-y_correct(:))<1e-4));