views:

636

answers:

3

I´m trying to solve this set of equations in MATLAB and I get an empty sym object:

equations = {'I2B+I2EQAB=I22B+I2EQBC',...
             'I2A=I2EQAB+I2EQAC+I22A',...
             'I2C+I2EQBC+I2EQAC=I22C',...
             'I22B=IZB+IC1B',...
             'IZB=IC2B+IZBB',...
             'I22C=-I2C*Z2C*YC/2+IZC',...
             'IZC=IC2C+IZCC',...
             'I22A=IC1A+IZA1',...
             'IC4A+IZA2=IZBB+IZCC',...
             'IZB*Z2LB+IC2B*2/YB=IC1B*2/YB',...
             'I2C*Z2C=-IC2C*2/YC+IZC*Z2LC',...
             'IZA1*m*Z2LA+IC2A*2/(m*YA)=IC1A*2/(m*YA)',...
             'IC4A*2/((1-m)*YA)=IC2A*2/(m*YA)+IZA2*(1-m)*Z2LA',...
             'I2EQBC*Z2EQBC+IZC*Z2LC=IZB*Z2LB',...
             'I2B*Z2B+IC1B*2/YB',...
             'I2C*Z2C+IC1C*2/YC',...
             'I2A*Z2A+IC1A*2/(m*YA)',...
             'IZB*Z2LB+(1-m)*Z2LA*IZA2=IZA1*m*ZL2A-I2EQAB*Z2EQAB',...
             'IZA1*m*Z2LA=IZA2*(1-m)*Z2LA+IZC*Z2LC+I2EQAC*Z2EQAC',...
             'IC4A/((1-m)*YA)=IC2C/YC'};
variables = {'m','I2A','I2B','I2C','I2EQAB','I2EQAC','I2EQBC',...
             'IZA1','IC1A','IC2A','IZA2','IC4A','IC1B','IZB',...
             'IC2B','IZBB','IZC','IC2C','IZCC'};
LL = solve(equations{:},variables{:})

Can you help me figure out what's going wrong?

+2  A: 
Warning: 20 equations in 19 variables. 
> In solve at 139
Warning: Explicit solution could not be found. 
> In solve at 170

LL =

[ empty sym ]

I think that's self explanatory, if not check out the documentation related to DSOLVE where:

Diagnostics If dsolve cannot find an analytic solution for an equation, it prints the warning: Warning: Explicit solution could not be found. and returns an empty sym object.

Jacob
A: 

I tried reformatting the equations and inputting directly into the symbolic toolbox, and the solve function just spits out all the equations, so it cannot solve for those variables as the current equations stand.

Do you have any knowledge about the domains or constraints for all those variables? If you do I'd look at specifying all those, perhaps it would allow the solver to find a solution for you.

To get you quickly up and running in the symbolic toolbox, here's your equations reformatted to fit:

equations := {
    I2B + I2EQAB                          = I22B + I2EQBC,
    I2A                                   = I2EQAB + I2EQAC + I22A,
    I2C + I2EQBC + I2EQAC                 = I22C,
    I22B                                  = IZB + IC1B,
    IZB                                   = IC2B + IZBB,
    I22C                                  = -I2C * Z2C * YC / 2 + IZC,
    IZC                                   = IC2C + IZCC,
    I22A                                  = IC1A + IZA1,
    IC4A + IZA2                           = IZBB + IZCC,
    IZB * Z2LB + IC2B * 2 / YB            = IC1B * 2 / YB,
    I2C * Z2C                             = -IC2C * 2 / YC + IZC * Z2LC,
    IZA1 * m * Z2LA + IC2A * 2 / (m * YA) = IC1A * 2 / (m * YA),
    IC4A * 2 / ((1 - m) * YA)             = IC2A * 2 / (m * YA) + IZA2 * (1 - m) * Z2LA,
    I2EQBC * Z2EQBC + IZC * Z2LC          = IZB * Z2LB,
    I2B * Z2B + IC1B * 2 / YB,
    I2C * Z2C + IC1C * 2 / YC,
    I2A * Z2A + IC1A * 2 / (m * YA),
    IZB * Z2LB + (1 - m) * Z2LA * IZA2    = IZA1 * m * ZL2A - I2EQAB * Z2EQAB,
    IZA1 * m * Z2LA                       = IZA2 * (1 - m) * Z2LA + IZC * Z2LC + I2EQAC * Z2EQAC,
    IC4A / ((1 - m) * YA)                 = IC2C / YC
}:

variables := {
    m, I2A, I2B, I2C, I2EQAB, I2EQAC ,I2EQBC,
    IZA1, IC1A, IC2A, IZA2, IC4A, IC1B, IZB,
    IC2B, IZBB, IZC, IC2C, IZCC
}:

solve(equations, variables)

To specify that all your known variables are real numbers, use this command:

assume(variables, Type::Real)

Also note that I count 36 unique variables (unless I made a mistake) in the equations, you'd be getting a huge list of "what-if's" for those equations if the solver was able to produce a result. I'd look at your equations and see if you could group them out and solve them in smaller sets.

Lasse V. Karlsen
Is that MuPAD code?
gnovice
Yes, it is, or the "symbolic toolbox" as it is known now that MathWorks purchased it and integrated it into Matlab.
Lasse V. Karlsen
A: 

Matlab, symbolic solve: solve()

I think has issues with symbolic variables who's names are more than one character.

a-z works, but anytime i try to solve something with two letters or more it just spits back out the empty set.

For instance, something as simple as solve('xy*10 = 1', 'xy') doesn't work :(

Daniel

related questions