Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduced Row Echelon of a Matrix containing unknown constants in Matlab

the problem:

    >> syms('a', 'b', 'c');

    >>A =

    [ -2, 3,  1, a]
    [  1, 1, -1, b]
    [  0, 5, -1, c]

    >>rref(A)

    ans =

    [ 1, 0, -4/5, 0]
    [ 0, 1, -1/5, 0]
    [ 0, 0,    0, 1]

The problem I'm having is that I need the answer to be in terms of a b and c, so I need something like:

    ans =
    [1, 0, 0, a+2b-c]
    [0, 1, 0, 3a-c]
    [0, 0, 1, a+b+c]

Is there any way to get Matlab to accomplish this?

like image 966
Zach Avatar asked Nov 19 '25 17:11

Zach


1 Answers

You just need to convert the problem to a relevant form in order to use rref properly, that is, instead of :

[1, 0, 0, a+2b-c]
[0, 1, 0, 3a-c]
[0, 0, 1, a+b+c]

where the x,y,z form the unity matrix block, write:

 syms x y z
 D =
[ 1, 2, -1, x]
[ 3, 0, -1, y]
[ 1, 1,  1, z]

rref(D)
ans =
[ 1, 0, 0,     (3*y)/10 - x/10 + z/5]
[ 0, 1, 0,       (2*x)/5 - y/5 + z/5]
[ 0, 0, 1, (3*z)/5 - y/10 - (3*x)/10]
like image 54
bla Avatar answered Nov 22 '25 09:11

bla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!