A long forgotten question and one with an answer that may not be appreciated by @Chloe St John, given that multiple questions by that poster were deleted after the fact. But I'll post an answer anyway, since I think the question is a valid one, and I think it never got a complete answer. In the second case,

C=[3 2 -7;5 -1 3;-6 -4 14];

You want to solve for a 3x1 vector X, such that

C*X == D

The common solution, when C is non-singular, is to use a tool like linsolve, or just backslash. But if we try backslash, for example

X = C\D

Warning: Matrix is singular to working precision.

X =

NaN
NaN
NaN

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

we get NaNs. This is because C is a singular matrix.

It has rank 2, but the matrix is 3x3. That tells us there are only 2 distinct pieces of information in that matrix, not 3. And that means, we cannot estimate (uniquely) 3 unknowns. Other tools are able to perform the task however. For example, lsqminnorm.

X0 = lsqminnorm(C,D)

X0 =

1.9991
-0.0418
-0.0123

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

Is that a valid solution, solving the system?

C*X0 - D

ans =

0
0
0

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

In fact, it is so. There is indeed a valid solution to the problem. However, there are infinitely many solutions. We can write them all in the general form

X_general = sym(X0) + t*null(sym(C))

X_general =

Now we can verify the general result.

C*X_general - D

ans =

So ANY vector of that form, for any value of the parameter t is a valid solution. And unfortunately, tools lilke backslash and linsolve don't have the capability to give you that result.

Finally, this problem did have a solution. We could have performed this test in advance, to know if an exact solution does exist. While the rank of C was 2, if we adjoiin the vector D to C, and then compute the rank again, if the rank is still 2, then an exact solution does exist, since D can then be written as a linear combination of the columns of C.

And since rank again returns 2, we see an exact solution must exist.