Basic matrix equation Ax=B with restrictions

Hi! Im modeling a truss using FEM and im trying to solve a very basic equation A*x=b where a is the stiffness matrix , x and b are the displacements and forces vectors. So A and b are known and i want to find x, the displacements. I know i could type x=b/A in matlab, the thing is i know some of the entries of the x vector due to boundary conditions, and typing a=b/A it works as if all x entries where unknowns. Is there a function to do this in MATLAB ?
Thanks a lot!!
Pd: Sorry for my poor english!

 채택된 답변

Greg Heath
Greg Heath 2011년 10월 9일

1 개 추천

x = [ x1 ; x2 ]% x2 known
A = [ A1 A2 ]% A1 & A2 known
A*x = A1*x1 + A2*x2 % last term known
A1*x1 = b - A2*x2
Voila!
Hope this helps.
Greg
P.S. Ain't Linear Systems grand?

추가 답변 (2개)

bym
bym 2011년 10월 9일

0 개 추천

you need to reduce the size of your stiffness and force matrix to eliminate those entries where you know the value of x. I call these Ared and bred. Then perform
xred = Ared\bred
then substitute the known values of x into xred and multiply by the stiffness matrix to get the full force matrix.
It is difficult to explain in words, if you can post your A b x then an example would be better
Dr. Seis
Dr. Seis 2011년 10월 9일

0 개 추천

If "x" and "b" are column vectors, then your system of equations is like:
A(1,1) * x(1,1) + A(1,2) * x(2,1) + ... + A(1,N) * x(N,1) = b(1,1)
A(2,1) * x(1,1) + A(2,2) * x(2,1) + ... + A(2,N) * x(N,1) = b(2,1)
...
A(M,1) * x(1,1) + A(M,2) * x(2,1) + ... + A(M,N) * x(N,1) = b(M,1)
If you already know some values of x, then move them to the right-hand side of your system of linear equations. For example, if you know the value of x(2,1) then your system of linear equations would be:
A(1,1) * x(1,1) + A(1,3) * x(3,1) + ... + A(1,N) * x(N,1) = b(1,1) - A(1,2) * x(2,1)
A(2,1) * x(1,1) + A(2,3) * x(3,1) + ... + A(2,N) * x(N,1) = b(2,1) - A(2,2) * x(2,1)
...
A(M,1) * x(1,1) + A(M,3) * x(3,1) + ... + A(M,N) * x(N,1) = b(M,1) - A(M,2) * x(2,1)
In this example (and if x(2,1) = 5), you would then redefine you matrices as follows:
b = b - A(:,2)*5;
A = A(:,1:N~=2);
You will find your new "x" as follows:
x = A\b;

댓글 수: 3

If you are using inv() you are probably doing something wrong!
The mldivide ('\') operator has no problem with non-square matrices.
Dr. Seis
Dr. Seis 2011년 10월 9일
The results *should* be identical in theory. However, in practice, using the x=A\b will offer more accuracy (as documented in the Help Navigation under "inv").
Dr. Seis
Dr. Seis 2011년 10월 9일
Updated x = A\b;
from x = inv(transpose(A)*A)*transpose(A)*b;

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by