简体   繁体   中英

Trying to solve an equation with unknown matrix in matlab

I am stuck in a simple problem. Assume we have two vectors which are known for example

v1 = (5 , 6 ,7) and v2 =(10,-40,30

and we want to find an unknown matrix A so that

v2 = A*v1

I tried

A = sym('A', [3 3])
equation = A *v1' - v2 == 0;

Solution = solve(equation)

however I get the following outcome

Solution = 

 struct with fields:

   A1_1: [0×1 sym]
   A1_2: [0×1 sym]
   A1_3: [0×1 sym]
   A2_1: [0×1 sym]
   A2_2: [0×1 sym]
   A2_3: [0×1 sym]
   A3_1: [0×1 sym]
   A3_2: [0×1 sym]
   A3_3: [0×1 sym]

where every value is Empty sym: 0-by-1 What am I doing wrong?

I also made v1 and v2 column vectors and did the matrix division, but the values I get for A are different than what ThomasIsCoding got.

v1 = [5 , 6 ,7]';
v2 = [10, -40, 30]';
A = v2/v1

A =

         0         0    1.4286
         0         0   -5.7143
         0         0    4.2857

When you check if A*v1 = v2, it does, so my solution is correct

>> A*v1

ans =

    10
   -40
    30

I think this problem may have multiple solutions.

You are missing a transpose. Try this:

equation = A *v1' - v2' == 0
Solution = solve(equation, A)

Maybe you can try the matrix division like below

>> v2'/v1'
ans =

   0.4545   0.5455   0.6364
  -1.8182  -2.1818  -2.5455
   1.3636   1.6364   1.9091

such that

>> ans*v1'-v2'
ans =

   3.5527e-15
  -1.4211e-14
   1.4211e-14

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM