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(l1^2-l4^2+l3x^2+l3y^2+l3z^2+p4x^2+p4y^2+p4z^2+s_x^2+s_y^2+s_z^2+2*l3y*o_1y+2*l3z*o_1z-2*o_1x*p4x-2*l3y*p4y-2*o_1y*p4y-2*l3z*p4z+2*l3x*(o_1x-p4x-s_x)-2*o_1x*s_x+2*p4x*s_x-2*l3y*s_y-2*o_1y*s_y+2*p4y*s_y-2*l3z*s_z+2*p4z*s_z)+c2*c3^2*(l1^2-l4^2+l3x^2+l3y^2+l3z^2+p4x^2+p4y^2+p4z^2+s_x^2+s_y^2+s_z^2-2*l3y*o_1y+2*l3z*o_1z-2*o_1x*p4x+2*l3y*p4y-2*o_1y*p4y-2*l3z*p4z-2*o_1x*s_x+2*p4x*s_x+2*l3x*(-o_1x+p4x+s_x)+2*l3y*s_y-2*o_1y*s_y+2*p4y*s_y-2*l3z*s_z...
+2*p4z*s_z)+c2^3*(l1^2-l4^2+l3x^2+l3y^2+l3z^2+p4x^2+p4y^2+p4z^2+s_x^2+s_y^2+s_z^2+2*l3y*o_1y-2*l3z*o_1z-2*o_1x*p4x-2*l3y*p4y-2*o_1y*p4y+2*l3z*p4z-2*o_1x*s_x+2*p4x*s_x+2*l3x*(-o_1x+p4x+s_x)-2*l3y*s_y-2*o_1y*s_y+2*p4y*s_y+2*l3z*s_z+2*p4z*s_z)-2*c2^2*c3*(o_1z*(p4y+s_y)+2*l3z*(-o_1y+p4y+s_y)+2*l3y*(-o_1z+p4z+s_z))+c2^2*(4*l3z*(o_1x-p4x-s_x)-2*l3x*(o1z-2*(p4z+s_z)))];
Error using ^
Matrix must be square.
why?

採用された回答

Rik
Rik 2021 年 12 月 22 日
Lets take a third power as example.
A is n by m
A^3 = A*A*A = [n x m]*[n x m]*[n x m]
To be compatible, adjacent sizes must be equal
Therefore, for this operation to be valid, n and m must be equal
If instead you meant element-wise operations, you should replace all matrix operation with the other version. That means replacing every * with .* and every ^ with .^ (plus and minus will always work element-wise).
I hope this formula was generated procedurally and not written by hand, because that would be a nightmare to debug. Especially with all those numbered variables, instead of arrays.
  1 件のコメント
sebastiano della gatta
sebastiano della gatta 2021 年 12 月 22 日
thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Loops and Conditional Statements in Help Center and File Exchange

タグ

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by