Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to solve 4 equations in matlab!

Status
Not open for further replies.

lou1234

Materials
Apr 3, 2014
4
Hi I am trying to solve the following equations using Matlab for C1, C2, C3 and C4. In real fact I only require C1.

C1-C2-C3-1=0
n*C2+C3/n+(d-1)*C4=0
C1+b*C2-b*C3-1=0
b*n*C2-b*C3/n-C4(1+d)=0

This is what I have input in Matlab but it seems its getting stuck because of the symbolic expresssion??

Any help please?

syms C1 C2 C3 C4 g L g_0 dL
n=exp(-g*L)
d=exp(-2*g_0*dL)
solve(C1-C2-C3-1, n*C2+C3/n+(d-1)*C4, C1+b*C2-b*C3-1, b*n*C2-b*C3/n-C4(1+d), C1)
 
Replies continue below

Recommended for you

I can't help but notice you have 4 equations and 4 unknowns, and your homework is to solve it in a programming environment called matrix laboratory.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
g, L, dL are also unknown by that expression


"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
and g_0


"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
I would like to solve for c1 in terms of g_0, DL etc..
 
You still have more unknowns than equations..


"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
Having more unknowns can yield many solutions. Here is what maple gave me:
Code:
> B := solve({n*C2+C3/n+(d-1)*C4 = 0, b*n*C2-C3/n-(1+d)*C4 = 0, C1-C2-C3-1 = 0, C1+b*C2-b*C3-1 = 0});
print(`output redirected...`); # input placeholder
     /                                                
     |     2 b C3 + 1 + b       C3 (-1 + b)           
    < C1 = --------------, C2 = -----------, C3 = C3, 
     |         1 + b               1 + b              
     \                                                

           1          1              
      C4 = - n C3 b - - n C3, b = b, 
           2          2              

                  2  2        2        2       \   
          -2 b + b  n  - 2 b n  - 2 + n        |   
      d = ------------------------------, n = n >, 
                2                              |   
               n  (-1 + b) (1 + b)             /   

      {C1 = 1, C2 = 0, C3 = 0, C4 = 0, b = b, d = d, n = n}
>


"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
I have 4 equations and I need to find c1, c2, c3 and c4, so 4 equations, 4 unknowns
 
So put numbers (real values) in for those other symbolic representations and you are done in about 10 seconds.


"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
Can't do that as I require a general expression. Is that possible in Matlab? Any idea why my code is not working?

 
I was trying to see if you understood your fundamental mistake. You are NOT differentiating between constants and variables in your work. That is why I say you have more variables. Matlab thinks there are more than there are.

All you need to do it tell it which ones are vars. ...

Code:
Q= solve('C1-C2-C3-1','n*C2+C3/n+(d-1)*C4','C1+b*C2-b*C3-1','b*n*C2-b*C3/n-C4(1+d)','C1','C2','C3','C4');

Q.C1




"Simplicity is the ultimate sophistication." L. da Vinci
- Gian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor