Is zero a valid solution? It appears to be so. (By the way, you don't put the names of the variables in quotes to call solve. But you knew that from the first time you used solve, in the case that you claim did work.)
Your system appears to be linear. It has no right hand side. Thus it is effectively a linear system with no constant right hand side. zero is avalid solution. Even if I missed a product in there between two of the unknowns, it is still one with a zero right hand side as far as I can see.
A valid solution to any such system is ZERO.
Worse, it looks like you have 27 equations, and 29 unknowns? I'm actually surprised that solve gave you any solution at all, since the system is under-determined. So there will be infinitely many solutions.
So, next, lets see what equationsToMatrix tells us about your linear system.
[M2,rhs2] = equationsToMatrix(eq0,eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,eq13,eq14,eq15,eq16,eq17,eq18,eq19,eq20,eq21,eq22,eq23,eq24,eq25,eq26,[i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,e3,e4,e5,e6,e7,e8,e9]);
As I thought, the system is homogeneous, rhs is identically zero.
rhs2'
ans =
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
We see the system is indeed 27x29, so it is underdetermined.
There are infinitely many solutions, one of which is the all zero solution. Of course this must be true, because it is trivially true that M2*zeros(29,1)=0.
To go back and answer your question, why did the solve work the firt time you used solve?
[M1,rhs1] = equationsToMatrix([eq0,eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,eq13,eq14, eq15, eq16, eq17, eq18], [i1,i2,i3,i4,i5,i6,i7,v1,v2,v3,v4,v5,v6,v7,e1,e2,e3,e4,e5]);
It worked because your system is not homogeneous there.
rhs1
rhs1 =
0
0
0
0
0
0
0
0
0
0
0
0
va
0
0
vb
0
0
0
As you can see, the right hand side is NOT identically zero.
So why did you get zero the second time? Linear Algebra 101.
Does a non-zero solution to the second problem exist? Yes, infinitely many of them, and no great way to choose which solution you might like.
So, any linear combination of the columns of
null(M2)
ans =
[ -1/R3, (A + 1)/(A*R3)]
[ 0, -(R2 + R3 + A*R2)/(A*R3*(2*R1 + Rg))]
[ 0, -(R2 + R3 + A*R2)/(A*R3*(2*R1 + Rg))]
[ 0, (R2 + R3 + A*R2)/(A*R3*(2*R1 + Rg))]
[ -1/R3, (A + 1)/(A*R3)]
[ 1/R3, 0]
[ -1/R3, (A + 1)/(A*R3)]
[ 1/R3, 0]
[ 1/R3, (R2 + R3 + A*R2)/(A*R3*(2*R1 + Rg))]
[ 1/R3, -(2*R1 + R2 + R3 + Rg + 2*A*R1 + A*R2 + A*Rg)/(A*R3*(2*R1 + Rg))]
[ (R2 + R3 + A*R2 + A*R3)/(A*R3), -((A + 1)*(R2 + R3 + A*R2))/(A^2*R3)]
[ (R2 + R3 + A*R2 + A*R3)/(A*R3), -(R1*(R2 + R3 + A*R2))/(A*R3*(2*R1 + Rg))]
[ -R2/R3, (R2 + A*R2)/(A*R3)]
[ 0, -(R1*(R2 + R3 + A*R2))/(A*R3*(2*R1 + Rg))]
[ 0, -(R2*Rg + R3*Rg + A*R2*Rg)/(A*R3*(2*R1 + Rg))]
[ 0, (R1*(R2 + R3 + A*R2))/(A*R3*(2*R1 + Rg))]
[ -1, (A + 1)/A]
[ R2/R3, 0]
[ 0, 1]
[ 1, 0]
[ (R2 + R3)/R3, 0]
[ (R2 + R3)/R3, -(R2 + R3 + A*R2)/(A*R3)]
[ (R2 + R3)/R3, -(R2 + R3 + A*R2)/(A*R3)]
[ (R2 + R3)/R3, -((R1 + Rg)*(R2 + R3 + A*R2))/(A*R3*(2*R1 + Rg))]
[ (R2 + R3)/R3, -(R1*(R2 + R3 + A*R2))/(A*R3*(2*R1 + Rg))]
[ (R2 + R3)/R3, 0]
[ 1, -1/A]
[ 1, 0]
[ 0, 1]
will yield a valid solution to your problem.
Again, linear algebra. It is a good class to take, if you will then be using linear algebra.
Best Answer