This is a 3*5 matrix and there are 2 free variables. I don't know if this is the best way to solve this in MATLAB. But it doesn't work and output Empty sym: 0-by-1
clear x_1 x_2 x_3 x_4 x_5
syms x_1 x_2 x_3 x_4 x_5
eqn1 = x_1+0*x_2+3*x_3+2*x_4-4*x_5==4 ;
eqn2 = 2*x_1+x_2+6*x_3+5*x_4+0*x_5==7 ;
eqn3 = -x_1+x_2-3*x_3-x_4+x_5==-5 ;
tic ;
res = solve([eqn1,eqn2,eqn3]) ;
toc ;
You don't need the symbolic math toolbox for a simple system of linear equations. You're better off using
mldivide, which is common enough that it has the shorthand\.For a system
Ax = b, wherexis a vector of x values,Ais a matrix of coefficients, andbis their product (right hand side of your system), you can solve it bySo
You can manually check that this result (
x3=2, x4=-1, x1=x2=x5=0) works.