Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Solving Matrix Equations

Subject: Solving Matrix Equations

From: Shaun Hurley

Date: 15 Feb, 2011 14:13:04

Message: 1 of 13

Hello All,
Is there a nice easy way to solve matrix equations? I have a problem that looks like:
K = [1,-1,0;-1,2,-1;0,-1,1]
d = [x;y;0]
F = [-16.98;-33.96;z-16.98]
F = K*d
There must be a built in solver. Any ideas? Thanks in advance!

Subject: Solving Matrix Equations

From: Nasser M. Abbasi

Date: 15 Feb, 2011 14:46:41

Message: 2 of 13

On 2/15/2011 6:13 AM, Shaun Hurley wrote:
> Hello All,
> Is there a nice easy way to solve matrix equations? I have a problem that looks like:
> K = [1,-1,0;-1,2,-1;0,-1,1]
> d = [x;y;0]
> F = [-16.98;-33.96;z-16.98]
> F = K*d
> There must be a built in solver. Any ideas? Thanks in advance!

Yes, there is. Re-Write it as Au=b, where x is your unknowns (x,y,z)
in your example.

Then type A\b and Matlab should solve it.

--Nasser

Subject: Solving Matrix Equations

From: Shaun Hurley

Date: 15 Feb, 2011 16:49:05

Message: 3 of 13

I'm sorry I'm not understanding what you mean by re-write it. Where are you getting Au and b? I am somewhat of a beginner when it comes to MATLAB. Thank you again.

Subject: Solving Matrix Equations

From: Nasser M. Abbasi

Date: 15 Feb, 2011 17:14:45

Message: 4 of 13

On 2/15/2011 8:49 AM, Shaun Hurley wrote:
> I'm sorry I'm not understanding what you mean by re-write it. Where are you getting
>Au and b? I am somewhat of a beginner when it comes to MATLAB. Thank you again.

You had 3 equations in x,y,z if I remember.

Just write them as A u = b, where A is 3x3 coefficient matrix,
u will be the vector of the unknowns (x,y,z) and b the vector
of the RHS.

Just take a paper and write them down, you'll see A and b show
up. Then go back to Matlab, and type in A and b as they
came up in that piece of paper, and then type A\b.

Matlab will give you back the solution.

--Nasser

Subject: Solving Matrix Equations

From: Shaun Hurley

Date: 15 Feb, 2011 19:57:03

Message: 5 of 13

I'm sorry I'm not understanding what you mean by re-write it. Where are you getting Au and b? I am somewhat of a beginner when it comes to MATLAB. Thank you again.

Subject: Solving Matrix Equations

From: Shaun Hurley

Date: 15 Feb, 2011 19:58:03

Message: 6 of 13

I see, but z is a variable on the other side of the equation. I could use that to help me eventually obtain the answer, but is there a direct way to solve?

Subject: Solving Matrix Equations

From: Nasser M. Abbasi

Date: 16 Feb, 2011 06:07:32

Message: 7 of 13

On 2/15/2011 11:58 AM, Shaun Hurley wrote:

> I see, but z is a variable on the other side of the equation. I could use that to
> help me eventually obtain the answer, but is there a direct way to solve?

"Hello All,
Is there a nice easy way to solve matrix equations? I have a problem that looks like:
K = [1,-1,0;-1,2,-1;0,-1,1]
d = [x;y;0]
F = [-16.98;-33.96;z-16.98]
F = K*d
There must be a built in solver. Any ideas? Thanks in advance!"

I think your equations are the same as this A u = b system, but
you should double check.

EDU>> A=[1 -1 0;-1 2 0;0 -1 -1]
A =
      1 -1 0
     -1 2 0
      0 -1 -1

EDU>> b=[-16.98; -33.96; -16.98]
b =
   -16.9800
   -33.9600
   -16.9800

EDU>> A\b
ans =
   -67.9200
   -50.9400
    67.9200

So, there is your solution above, shown in x,y,z order

I do not know what you mean by a "direct" way to solve them.

A\b is a direct way.

--Nasser

Subject: Solving Matrix Equations

From: proecsm

Date: 16 Feb, 2011 18:09:04

Message: 8 of 13

"Nasser M. Abbasi" <nma@12000.org> wrote in message <ijfpj9$v7m$1@speranza.aioe.org>...
> On 2/15/2011 11:58 AM, Shaun Hurley wrote:
>
> > I see, but z is a variable on the other side of the equation. I could use that to
> > help me eventually obtain the answer, but is there a direct way to solve?
>
> "Hello All,
> Is there a nice easy way to solve matrix equations? I have a problem that looks like:
> K = [1,-1,0;-1,2,-1;0,-1,1]
> d = [x;y;0]
> F = [-16.98;-33.96;z-16.98]
> F = K*d
> There must be a built in solver. Any ideas? Thanks in advance!"
>
> I think your equations are the same as this A u = b system, but
> you should double check.
>
> EDU>> A=[1 -1 0;-1 2 0;0 -1 -1]
> A =
> 1 -1 0
> -1 2 0
> 0 -1 -1
>
> EDU>> b=[-16.98; -33.96; -16.98]
> b =
> -16.9800
> -33.9600
> -16.9800
>
> EDU>> A\b
> ans =
> -67.9200
> -50.9400
> 67.9200
>
> So, there is your solution above, shown in x,y,z order
>
> I do not know what you mean by a "direct" way to solve them.
>
> A\b is a direct way.
>
> --Nasser
>
Nasser's method is not entirely correct. you have to eliminate the unknown force and corresponding elements from the stiffness matrix before you solve the the equations. This is because the stiffness matrix is singular. You can prove this to youself by doing det(K) , which is zero. Once you solve the equation, you use f= K*d to get the unknown force

clc clear

F = [-16.98;-33.96;nan]
K = [1,-1,0;-1,2,-1;0,-1,1]

A = K(1:2,1:2);
b = F(1:2);

d = A\b;
d(3) = 0;

F= K*d
% Check
sum(F)==0

Subject: Solving Matrix Equations

From: Nasser M. Abbasi

Date: 16 Feb, 2011 19:15:26

Message: 9 of 13

On 2/16/2011 10:09 AM, proecsm wrote:
> "Nasser M. Abbasi"<nma@12000.org> wrote in message<ijfpj9$v7m$1@speranza.aioe.org>...
>> On 2/15/2011 11:58 AM, Shaun Hurley wrote:
>>
>>> I see, but z is a variable on the other side of the equation. I could use that to
>>> help me eventually obtain the answer, but is there a direct way to solve?
>>
>> "Hello All,
>> Is there a nice easy way to solve matrix equations? I have a problem that looks like:
>> K = [1,-1,0;-1,2,-1;0,-1,1]
>> d = [x;y;0]
>> F = [-16.98;-33.96;z-16.98]
>> F = K*d
>> There must be a built in solver. Any ideas? Thanks in advance!"
>>
>> I think your equations are the same as this A u = b system, but
>> you should double check.
>>
>> EDU>> A=[1 -1 0;-1 2 0;0 -1 -1]
>> A =
>> 1 -1 0
>> -1 2 0
>> 0 -1 -1
>>
>> EDU>> b=[-16.98; -33.96; -16.98]
>> b =
>> -16.9800
>> -33.9600
>> -16.9800
>>
>> EDU>> A\b
>> ans =
>> -67.9200
>> -50.9400
>> 67.9200
>>
>> So, there is your solution above, shown in x,y,z order
>>
>> I do not know what you mean by a "direct" way to solve them.
>>
>> A\b is a direct way.
>>
>> --Nasser
>>

> Nasser's method is not entirely correct. you have to eliminate the
> unknown force and corresponding elements from the stiffness matrix
> before you solve the the equations. This is because the stiffness matrix is
> singular. You can prove this to youself by doing det(K) , which is zero.
> Once you solve the equation, you use f= K*d to get the unknown force
>
> clc clear
>
> F = [-16.98;-33.96;nan]
> K = [1,-1,0;-1,2,-1;0,-1,1]
>
> A = K(1:2,1:2);
> b = F(1:2);
>
> d = A\b;
> d(3) = 0;
>
> F= K*d
> % Check
> sum(F)==0

It not a "method". I simply wrote down the equations as given. I am
going by the assumpetion that x,y,z are the unknowns. OP said to
"solve" the equations, and I see x,y,z in there, so I am
solving by finding x,y,z which satisfy the set of equations?

Lets go over this again, just math. no "stiffness" business here.

The given F = K*d above is just the following written out:

-16.98 = x - y
-33.96 = -x +2 y
z - 16.98 = -y

Are we OK so far?

The above is just

-16.98 = x - y
-33.96 = -x +2 y
- 16.98 = -y - z

Which in matrix form

A u = b

Where

>> A =
>> 1 -1 0
>> -1 2 0
>> 0 -1 -1
>>
>> EDU>> b=[-16.98; -33.96; -16.98]
>> b =
>> -16.9800
>> -33.9600
>> -16.9800
>>

So, I just did A\b to solve it.

?

--Nasser

Subject: Solving Matrix Equations

From: Bruno Luong

Date: 16 Feb, 2011 19:59:05

Message: 10 of 13

"proecsm" wrote in message <ijh3s0$ddp$1@fred.mathworks.com>...
>
> >
> Nasser's method is not entirely correct.

Nasser's method is correct. Thus your statement is incorrect.

Bruno

Subject: Solving Matrix Equations

From: proecsm

Date: 16 Feb, 2011 23:56:03

Message: 11 of 13

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ijhaa9$k2s$1@fred.mathworks.com>...
> "proecsm" wrote in message <ijh3s0$ddp$1@fred.mathworks.com>...
> >
> > >
> > Nasser's method is not entirely correct.
>
> Nasser's method is correct. Thus your statement is incorrect.
>
> Bruno

My apologies, I should have said the OP problem was poorly phrased by introducing z to represent an _unknown_ . If you look at the OP, they state d = [x;y;0], thus when Nasser says:

>The given F = K*d above is just the following written out:

>-16.98 = x - y
>-33.96 = -x +2 y
>z - 16.98 = -y

>Are we OK so far?

I'd have to say *no*. Taking the context of the OP as it relates finite element analysis, I was trying to point out the general finite element workflow by reducing K to account for constraints, then using the displacement solution to find unknown forces.

Subject: Solving Matrix Equations

From: Martin Kovac

Date: 3 Mar, 2013 16:38:08

Message: 12 of 13

Please I have o problem and I can your help. I have defined:

M=U'AU

where U'U=I and A is a diagonal matrix containing the eigenvalues of M. Please how can I find corespondent matrix U? M,U,A are matrix and M is known matrix.

note: symbol ' means transpose operation.

Thanks a lot

Subject: Solving Matrix Equations

From: Bruno Luong

Date: 3 Mar, 2013 19:43:09

Message: 13 of 13

"Martin Kovac" <kovac.kovi@gmail.com> wrote in message <kgvu9g$1cs$1@newscl01ah.mathworks.com>...
> Please I have o problem and I can your help. I have defined:
>
> M=U'AU
>
> where U'U=I and A is a diagonal matrix containing the eigenvalues of M. Please how can I find corespondent matrix U? M,U,A are matrix and M is known matrix.

help eig
help svd

Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us