CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   [MATLAB] 9 equations, 9 unknowns (https://www.cfd-online.com/Forums/main/86629-matlab-9-equations-9-unknowns.html)

nakor March 28, 2011 16:47

[MATLAB] 9 equations, 9 unknowns
 
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:

http://img4.hostingpics.net/pics/619244systeme2.jpg

Do you think that I could solve it ?

Thank you for your help!

Eezyville March 28, 2011 18:24

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.

f-w March 28, 2011 18:42

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

nakor March 29, 2011 03:32

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...

Eezyville March 29, 2011 08:25

Did you try what f-w suggested? If that doesn't work then try solving them as individual equations.

nakor March 29, 2011 08:38

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.

Martin Hegedus March 29, 2011 12:28

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 March 29, 2011 13:42

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.

nakor March 30, 2011 07:06

Thanks Martin, I think I found something way easier to solve.

http://img4.hostingpics.net/pics/139920matrice.jpg

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 ?

Martin Hegedus March 30, 2011 12:48

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. :p

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.

srinu02062 March 31, 2011 07:33

u can try data fit software
by using multiple functions such as F1(s), F2(s)

Jonas Holdeman April 2, 2011 09:44

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 April 2, 2011 10:28

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?


All times are GMT -4. The time now is 05:31.