# How I can get coefficients matrix in MATLAB from the set of linear equations?

I am working in MATLAB and having problem in extraction of coefficients out of my set of symbolic linear equations. Equations are as such

R =

[0.8978*c - 0.8047*b - 0.020299*a,  0.8978*d - 0.094800*b - 0.106799*a]

[ 0.091199*a + 0.13200*c - 0.8047*d, 0.091199*b - 0.106799*c + 0.0575*d]


How I can get the coefficient matrix, that is my result will look like

R_coeff =

-0.0203   -0.8047    0.8978         0
-0.1068   -0.0948         0    0.8978
0.0912         0    0.1320   -0.8047
0    0.0912   -0.1068    0.0575


Thanks

-
@macydanim , can you please write steps using the following function? Because I am not able to do with it. – Salman Jan 25 '13 at 11:37

Using function subs should do the work:

res = subs(R,{a,b,c,d},{[1,0,0,0],[0 1 0 0],[0 0 1 0],[0 0 0 1]})


and then you have to play with the order to get it in the matrix format you want, e.g.,

R_coeff = [res(1,1:4);res(1,5:8);res(2,1:4);res(2,5:8)]

-

you can take derrivative according to a (b) (c) to get coefficient according to a(b) (c) and form your own matrice,

or you can use coeffs function and also form your own matrix.

-