Problem 796. Removing rows from a matrix is easy - but what about inserting rows?
Solution Stats
Problem Comments
-
3 Comments
Many of the test cases are wrong.
For example:
A = (1:2:10)';
IND = 1:5;
b = (2:2:10)';
y_correct = (1:10)';
y_correct should be [2:2:10,1:2:10]'
The zeros one has zeros that are the wrong size etc.
I corrected one error regarding isequal with NaNs, but all the other test cases are correct.
A = [1 3 5 7 9]; IND = [1 2 3 4 5]; b = [2 4 6 8 10]; definitely should result in [1 2 3 4 5 6 7 8 9 10]! You have to insert b(1) after A(1), b(2) after A(2) and so on.
Nice problem, but the specification could be improved: from the description, you'd think the entire matrix b is supposed to be inserted after each row in IND; it's only the first example that makes it clear that this is not the case.
Solution Comments
Show commentsProblem Recent Solvers199
Suggested Problems
-
556 Solvers
-
Project Euler: Problem 7, Nth prime
1283 Solvers
-
How many trades represent all the profit?
579 Solvers
-
640 Solvers
-
4169 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!