This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
A = 1;
IND = 1;
b = 1;
y_correct = [1;1];
assert(isequal(insertRows(A, IND, b), y_correct))
y =
1
0
|
2 | Fail |
A = [0 0; 1 1];
IND = [1 1 1 2];
b = NaN;
y_correct = [0 0;NaN NaN;NaN NaN;NaN NaN;1 1;NaN NaN];
assert(isequalwithequalnans(insertRows(A, IND, b), y_correct))
y =
NaN NaN
NaN NaN
NaN NaN
0 0
NaN NaN
0 0
|
3 | Fail |
A = [1 1; 3 3; 4 4];
IND = [1 3];
b = [2 2; 5 5];
y_correct = [1 1;2 2;3 3;4 4;5 5];
assert(isequal(insertRows(A, IND, b), y_correct))
y =
2 2 2
5 5 5
4 4 4
0 0 0
2 2 2
5 5 5
|
4 | Fail |
A = (1:2:10)';
IND = 1:5;
b = (2:2:10)';
y_correct = (1:10)';
assert(isequal(insertRows(A, IND, b), y_correct))
y =
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
9 9 9 9 9
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
0 0 0 0 0
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
0 0 0 0 0
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
0 0 0 0 0
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
|
5 | Fail |
A = zeros(10,5);
IND = [3,7];
b = rand(2,5);
y_correct = [zeros(3,5); b(1,:); zeros(4,5); b(2,:); zeros(3,5)];
assert(isequal(insertRows(A, IND, b), y_correct))
y =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341
0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341 0.1341
0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605 0.1605
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
|
6 | Pass |
assert(isempty(strfind(evalc('type insertRows'), 'regexp')));
|
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!