But what you did was not a correct solution to the linear system of equations.
The solution to the linear system of equations is most simply done via backslash. No symbolic solve is even necessary. I think you understood that from your comment, but are really looking to use the symbolic toolbox with solve.
A=[1 1; 1 -1];
B= [10; 2];
X = A\B
ans =
6
4
So you want to solve the linear system of equations: A*X = B. As you see, the solution is the vector [6;4]. Is that correct?
[A*X,B]
ans =
10 10
2 2
Yes, it is correct. Of course, you could have used solve to do the work too.
syms x1 x2
X = solve(A*[x1;x2] == B)
X =
struct with fields:
x1: [1×1 sym]
x2: [1×1 sym]
X.x1
ans =
6
X.x2
ans =
4
Or, if you want to use solve, but do so moredirectly, without converting the problem to one with matrix coefficients, we could do...
syms x1 x2
[x1,x2] = solve(x1+x2 == 10,x1-x2 == 2)
x1 =
6
x2 =
4
As you see by either approach, solve agrees with backslash. It even agrees with pencil and paper. If
x1 + x2 = 10
x1 - x2 = 2
Then just add the two equations together. We get
2*x1 = 12
Which clearly implies x1=6. Then you can go back and recover x2 from either of those equations. Thus...
6 + x2 = 10
So x2 = 4 drops out.