This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Ulrik
on 7 Oct 2016
I do not see what is wrong with my solution?
David Verrelli
on 24 Mar 2017
Consider the first iteration (I=1 & j=1). The variable "value" was initialised, so the first conditional test is true, hence this matrix element is set to 1 (no change!) and "value" is set to 0. However, instead of finishing this iteration (refer to the "continue" statement), a second "if" statement is encountered, and because "value" is now 0, this second conditional is also true, so the first matrix element is finally changed to 0!
You would have better luck with a single if statement that included "else".
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!