1

I wonder if there is any way how to made MATLAB solve the system of equation as this:

$ s\cdot x_1 = \frac {R_1L_2}{M^2-L_1L_2} x_1+ \frac {MR_2}{M^2-L_1L_2} x_2+\frac {M}{M^2-L_1L_2} x_3 - \frac {L_2}{M^2-L_1L_2} u + \frac{R_2M(M-L_1L_2-1)}{R1L2(L_1L_2-M^2)}+\frac{10}{R_1}$

$s \cdot x_2 = \frac{R_1M^2}{M(M^2-L_1L_2)} x_1 + \frac{L_1R_2}{M^2-L_1L_2}x_2 + \frac{L_1}{M^2-L_1L_2}x_3 - \frac{M}{M^2-L_1L_2} u$

$s \cdot x_3 = \frac1{C_1} x_2 + \frac{R_2}{L_1L_2-M^2}$

with the respect to $x_1$, $x_2$ and $x_3$. Others letters are parameters.

When I write intructions like this:

syms M L1 L2 R1 R2 C x1 x2 x3 C u

x=['x1', 'x2', 'x3'];

solve(['(M*x3)/(M^2 - L1*L2) - (L2*u)/(M^2 - L1*L2) + (L2*R1*x1)/(M^2 - L1*L2) + (M*R2*x2)/(M^2 - L1*L2)=s*x1-((R2*M(M-L1*L2-1))/(R1*L2(L1*L2-M^2))+10/R1)', '(L1*x3)/(M^2 - L1*L2) - (M*u)/(M^2 - L1*L2) + (R1*x1)/(M^2 - L1*L2) + (L1*R2*x2)/(M^2 - L1*L2)=s*x2', 'x2/C1=s*x3-R2/(L1*L2-M^2)'], x, 'VectorFormat')

The result is

Warning: 1 equations in 2 variables. New variables might be introduced.

In C:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\symengine.p>symengine at 54 In mupadengine.mupadengine>mupadengine.evalin at 97 In mupadengine.mupadengine>mupadengine.feval at 150 In solve at 160 In lap_matr at 5 Warning: Explicit solution could not be found. In solve at 169 In lap_matr at 5

ans =

[ empty sym ]

Is there any way and which one?

user50222
  • 978

2 Answers2

1

I do not use Matlab but let us speak about your specific system of equations.

You could notice that, from the third equation, you can extract $x_3$ as a function of $x_2$ $$x_3=\frac{{C_1} {R_2}+({L_1} {L_2}-M^2) {x_2}}{{C_1} s \left({L_1} {L_2}-M^2\right)}$$ If you plug what you obtain for $x_3$ into the second equation, you can, in a very similar manner, now extract $x_2$ as a function of $x_1$. Putting all together into the first equation, it becomes a linear equation in $x_1$. Solve it and go backward if you want.

I suppose that you could do that without any problem with Matlab : solve the third equation for $x_3$, solve the second equation for $x_2$ knowing $x_3$, solve the first equation for $x_1$ knowing $x_2$ and $x_3$.

I totally agree that this does not solve your problem. However, such an approach will avoid giving you the monstreous formulas you would get solving directly for $x_1$, $x_2$ and $x_3$.

Added later

You would get monstreous formulas because of your coefficients. What I suggest is that you first rewrite your equations as (for example) $$x_1 = a_1 x_1 + a_2 x_2+a_3 x_3 + a_4$$ $$x_2 = b_1 x_1 + b_2 x_2+b_3 x_3 + b_4$$ $$x_3 = c_1 x_2 + c_2$$ Now, proceed as I suggested and, hoping that I did not make any mistake, $$x_3 = c_1 x_2 + c_2$$ $$x_2=-\frac{{b_1} {x_1}+{b_3} {c_2}+{b_4}}{{b_2}+{b_3} {c_1}-1}$$ $$x_1=-\frac{{a_2} ({b_3} {c_2}+{b_4})+{a_3} (-{b_2} {c_2}+{b_4} {c_1}+{c2})-{a_4} ({b_2}+{b_3} {c_1}-1)}{-{a_1} ({b_2}+{b_3} {c_1}-1)+{a_2} {b_1}+{a_3} {b_1} {c_1}+{b_2}+{b_3} {c_1}-1}$$

Now, you could replace or not the coefficients you so introduced by their expressions and try to simplify. But I do not think this could be a good idea. Just think how you would do it in a program.

1

If you don't define all of your variables, have typos in your equations and mix old and new ways of using the symbolic toolbox, you shouldn't be surprised to not get an answer.

First, unless you're using an old version of Matlab, the modern way of specifying equations is not with strings. You should define your symbolic variables using syms (string equations like you used are ignorant of anything defined in your workspace). You didn't define C1 or s as symbolic variables so those need to be added. Equations can then be created by using the == operator (see documentation for examples). Your system can be solve simply with (you also were missing two * signs in the first equation):

syms M L1 L2 R1 R2 C1 s u x1 x2 x3
s = solve((M*x3)/(M^2 - L1*L2) - (L2*u)/(M^2 - L1*L2) + (L2*R1*x1)/(M^2 - L1*L2) + (M*R2*x2)/(M^2 - L1*L2)==s*x1-((R2*M*(M-L1*L2-1))/(R1*L2*(L1*L2-M^2))+10/R1),...
          (L1*x3)/(M^2 - L1*L2) - (M*u)/(M^2 - L1*L2) + (R1*x1)/(M^2 - L1*L2) + (L1*R2*x2)/(M^2 - L1*L2)==s*x2,...
          x2/C1==s*x3-R2/(L1*L2-M^2),x1,x2,x3)

However, this is a linear system ($A x = b$), so solve is overkill. Forming the $A$ matrix and $b$ vector and using sym/linsolve:

syms M L1 L2 R1 R2 C1 s u

ML12 = (M^2-L1*L2);
A(1,1) = R1*L2/ML12-s;
A(1,2) = M*R2/ML12;
A(1,3) = M/ML12;
A(2,1) = R1*M/(M*ML12);
A(2,2) = L1*R2/ML12-s;
A(2,3) = L1/ML12;
A(3,1) = 0;
A(3,2) = 1/C1;
A(3,3) = -s;

b(1,1) = u*L2/ML12+R2*M*(M-L1*L2-1)/(R1*L2*ML12)-10/R1;
b(2,1) = u*M/ML12;
b(3,1) = R2/ML12;

x = linsolve(A,b) % Essentially x = A\b
horchler
  • 3,203