Is it possible to rewrite these equation set to matrix form?

39 Views Asked by At

I am dealing with some equation set to calculate coefficients b in Matlab. The equation set is as below. The x y z are the inputs vector in size 4. b is output vector, size 4.

b(1) = y3*z2 - y2*z3 + y2*z4 - y4*z2 - y3*z4 + y4*z3;
b(2) = y1*z3 - y3*z1 - y1*z4 + y4*z1 + y3*z4 - y4*z3;
b(3) = y2*z1 - y1*z2 + y1*z4 - y4*z1 - y2*z4 + y4*z2;
b(4) = y1*z2 - y2*z1 - y1*z3 + y3*z1 + y2*z3 - y3*z2;

The equation set would be calculation many times. It takes long time. I want to speed it up. I would like to rewrite this equation set into matrix multiplication, like b = A*[x,y,z] *C . So I could calculate the vector b in one time , not 4 times, in Matlab. Is it possible?

1

There are 1 best solutions below

1
On BEST ANSWER

You could write it as $$ \left[ \begin{array}{ccc} &(y_3 - y_4) & (y_4- y_2)& (y_2 - y_3) \\ (y_4 - y_3)& & (y_1- y_4)& (y_3 - y_1) \\ (y_2 - y_4)& (y_4 - y_1)& & (y_1 - y_2)& \\ (y_3 - y_2)& (y_1 - y_3)& (y_2 - y_1)& \\ \end{array} \right] \left[ \begin{array}{ccc} z_1 \\ z_2 \\ z_3 \\ z_4 \end{array} \right] $$