Question (1) is a simple LA exercise, but [A] needs to be 2-by-2. And then you can compute the roots of the system using linsolve(), ldivide(), \, etc operators.
Question (2): again the size of D is incorrectly defined. number of elements in each row has to be equal. Or D has to be row or column matrix containing some "0" elements. Once you fix this issue, you can solve the problem using logical indexing, e.g.: D(D==0) = [ ].