CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

[MATLAB] 9 equations, 9 unknowns

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   March 28, 2011, 16:47
Default [MATLAB] 9 equations, 9 unknowns
  #1
New Member
 
Romain
Join Date: Jun 2010
Location: Lyon
Posts: 28
Rep Power: 7
nakor is on a distinguished road
Hello,

I do not know anything about matlab but I have a rather complicated problem to solve, and I'm afraid that Excel will not suffice to solve it, so I was wondering if there was not an algorithm that could solve my system with Matlab.

Using AX = Y with my matrix A, which contains unknowns (sadly!), my X vector containing the values ​​that I seek, my solution vector Y (also with one unknow, X7...), I can get the following system:



Do you think that I could solve it ?

Thank you for your help!
nakor is offline   Reply With Quote

Old   March 28, 2011, 18:24
Default
  #2
New Member
 
Chris
Join Date: Oct 2010
Location: Cincinnati, OH
Posts: 24
Rep Power: 6
Eezyville is on a distinguished road
Send a message via Skype™ to Eezyville
Invert the matrix and multiply that by the solution vector to get X1-9.

if its Ax = b then do x = inv(A)*b

b must be a column vector.
Eezyville is offline   Reply With Quote

Old   March 28, 2011, 18:42
Default
  #3
f-w
Senior Member
 
Join Date: Apr 2009
Posts: 129
Rep Power: 8
f-w is on a distinguished road
You have more than 9 unknowns; furthermore, Excel will not be able to handle your constants in matrix A.

Looks like you need to symbolically solve a nonlinear system of equations, try the symbolic toolbox in MATLAB:
http://www.mathworks.com/help/toolbo...lic/solve.html
f-w is offline   Reply With Quote

Old   March 29, 2011, 03:32
Default
  #4
New Member
 
Romain
Join Date: Jun 2010
Location: Lyon
Posts: 28
Rep Power: 7
nakor is on a distinguished road
I can't use X=inv(A)*b since it's nonlinear. I have somes unknowns in both X,Y (Y6=-l+l*exp(gm)*exp(-gX7) with X7 unknown) and in my matrix (M(8,8)=f*X7-k, M(9,9)=exp(gm)*exp(-gX7)).

So I should try "solve(eq1, eq2, ..., eq9)" without using a matrix ?
Or, I could use my matrix to define each of my equations, like eq1=M(1,1)*X1+M(1,2)*X2+M(1,3)*X3, eq2=M(2,1)*X1...

Last edited by nakor; March 29, 2011 at 03:52.
nakor is offline   Reply With Quote

Old   March 29, 2011, 08:25
Default
  #5
New Member
 
Chris
Join Date: Oct 2010
Location: Cincinnati, OH
Posts: 24
Rep Power: 6
Eezyville is on a distinguished road
Send a message via Skype™ to Eezyville
Did you try what f-w suggested? If that doesn't work then try solving them as individual equations.
Eezyville is offline   Reply With Quote

Old   March 29, 2011, 08:38
Default
  #6
New Member
 
Romain
Join Date: Jun 2010
Location: Lyon
Posts: 28
Rep Power: 7
nakor is on a distinguished road
It could not work. It is a system, it will not work if I try to solve each equation individually.
I will try with "solve(eq1, eq2, ..., eq9)" as f-w suggested.
nakor is offline   Reply With Quote

Old   March 29, 2011, 12:28
Default
  #7
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 467
Rep Power: 9
Martin Hegedus is on a distinguished road
Why not just reduce the matrix, at least partially, by hand and see what it gets you?

By adding and subtracting various rows you can remove X4 and X6. Once that is done, maybe a couple other columns could go.
Martin Hegedus is offline   Reply With Quote

Old   March 29, 2011, 13:42
Default
  #8
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 467
Rep Power: 9
Martin Hegedus is on a distinguished road
Ooops, meant to say X5 instead of X4.

What you are looking to do is create a column with all 0s except one value. X5 is one such column already. X5 is dependent on the other variables, but none of the other equations are dependent on it. Once you add equation 8 to 7, then the same is true for X6. The goal is a triangular matrix by doing elimination and switching rows and columns.
Martin Hegedus is offline   Reply With Quote

Old   March 30, 2011, 07:06
Default
  #9
New Member
 
Romain
Join Date: Jun 2010
Location: Lyon
Posts: 28
Rep Power: 7
nakor is on a distinguished road
Thanks Martin, I think I found something way easier to solve.



I just have to found X9 first, then X8, X7... X1. It's even linear since I will know X7 when I will try to solve X4 and X3.
Can I use matlab to solve this system ?

Last edited by nakor; March 30, 2011 at 10:15.
nakor is offline   Reply With Quote

Old   March 30, 2011, 12:48
Default
  #10
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 467
Rep Power: 9
Martin Hegedus is on a distinguished road
I don't think matlab can solve it since I don't believe it does symbolic math. You'll need to use something like mathmatica. Or do it by hand.

One thing you can try, and I'm not sure this will work, is to take a look at equation 9 of your original matrix and take a best guess at the values for X7 and X9. From that equation is seems the best values may be that both are equal to l. However, it doesn't appear that a value of l for X9 would work in your reduced matrix.
Martin Hegedus is offline   Reply With Quote

Old   March 31, 2011, 07:33
Default
  #11
New Member
 
g srinivas
Join Date: Mar 2011
Posts: 2
Rep Power: 0
srinu02062 is on a distinguished road
u can try data fit software
by using multiple functions such as F1(s), F2(s)
srinu02062 is offline   Reply With Quote

Old   April 2, 2011, 09:44
Default
  #12
Member
 
Jonas T. Holdeman, Jr.
Join Date: Mar 2009
Location: Knoxville, Tennessee
Posts: 94
Rep Power: 9
Jonas Holdeman is on a distinguished road
MATLAB has an add-on symbolic toolkit that uses the MAPLE kernel for symbolic computations. I have not used this toolkit, but routinely use MAPLE. MAPLE has a very good linear symbolic solver that can solve linear equations with 100-200 variables in a few seconds. The MAPLE nonlinear solver can take a very long time with a smaller number of variables.

A suggestion would be to solve the linear subset of equations in terms of the nonlinear variables, then substitute solution into the nonlinear set (using the "subs" command) giving a smaller number of nonlinear equations. This is what Martin Hedegus was suggesting doing by hand. If the nonlinear solver cannot return a solution, then perhaps the smaller set of nonlinear equations can be simplified using some approximations, say for large or small limits of certain variables.

Often the nonlinear symbolic solver returns multiple solutions. For instance if you have a square root, there may be different solutions depending on the sign of the root.

Unfortunately, if the (linear) solver fails there is no information about why it failed, though this is usually due to inconsistent equations.
Jonas Holdeman is offline   Reply With Quote

Old   April 2, 2011, 10:28
Default
  #13
Member
 
Jonas T. Holdeman, Jr.
Join Date: Mar 2009
Location: Knoxville, Tennessee
Posts: 94
Rep Power: 9
Jonas Holdeman is on a distinguished road
A further thought. Simplify by replacing h1=exp(h), gm=exp(g*m), and renormizing X7'=X7/g .

In the simplified/reduced nonlinear equations, replace combinations of parameters appearing as coefficients by new parameters.

For small g, approximate exp(g*X7) by 1+g*X7 to linearize this term.

The solver has to make the most general assumptions about the parameters and variables. Can you tell the solver that certain things are real, or positive, or negative?
Jonas Holdeman is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide: Writing Equations in LaTeX on the CFD Online Forums pete Site Help, Feedback & Discussions 20 June 16, 2015 13:52
Question about UDS equations tstorm FLUENT 1 January 11, 2010 14:02
Maths problem when deriving conservation of energy equations. Demonwolf Main CFD Forum 1 June 15, 2009 14:21
? fluctuating equations for homogenous shear turb. ff_fan Main CFD Forum 1 September 20, 2002 07:39
Euler equations? Jan Ramboer Main CFD Forum 2 August 19, 1999 01:58


All times are GMT -4. The time now is 13:34.