I do not see what is wrong with my solution?
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".
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office