Inverse of 5x5 matrix

34 ビュー (過去 30 日間)
Syeda Nadiah Nahri
Syeda Nadiah Nahri 2019 年 10 月 11 日
コメント済み: Steven Lord 2019 年 10 月 11 日
Hi,
I am trying to obtain inverse of the following 5x5 matrix:
[ k_rot - C_M*s - C_rot*s + J_M*s^2, C_rot*s - k_rot, 0, 0, 0]
[ C_rot*s - k_rot, k_rot - C_S*s - C_rot*s + J_S*s^2 + i^2*k_n - C_n*i^2*s, 0, i*k_n - C_n*i*s, C_n*i*s - i*k_n]
[ 0, 0, k_B + k_ax - C_B*s - C_ax*s + M_B*s^2, C_ax*s - k_ax, 0]
[ 0, i*k_n - C_n*i*s, C_ax*s - k_ax, k_ax + k_n - C_ax*s - C_n*s + M_S*s^2, C_n*s - k_n]
[ 0, C_n*i*s - i*k_n, 0, C_n*s - k_n, k_n - C_g*s - C_n*s + M_T*s^2]
I used the following code in Matlab:
syms s k_rot C_M C_rot J_M J_S C_n i k_n M_B k_B k_ax C_B C_ax M_S M_T C_g C_S
A1 = ((s^2)*J_M)+(k_rot)-(s*C_M)-(s*C_rot);
A2 = (s*C_rot)-(k_rot);
A3 = (-k_rot)+(s*C_rot);
A4 = (s^2*J_S)+(k_rot)+(i^2*k_n)-(s*C_S)-(s*C_rot)-(i^2*s*C_n);
A5 = (i*k_n)-(i*s*C_n);
A6 = -(i*k_n)+(i*s*C_n);
A7 = (s^2*M_B)+(k_B)+(k_ax)-(s*C_B)-(s*C_ax);
A8 = -(k_ax)+(s*C_ax);
A9 = (i*k_n)-(i*s*C_n);
A10 = -(k_ax)+(s*C_ax);
A11 = (s^2*M_S)+(k_ax)+(k_n)-(s*C_ax)-(s*C_n);
A12 = -(k_n)+(s*C_n);
A13 = -(i*k_n)+(i*s*C_n);
A14 = -(k_n)+(s*C_n);
A15 = (s^2*M_T)+(k_n)-(s*C_n)-(s*C_g);
Arow1 = [A1 A2 0 0 0];
% Arow1 = [ k_rot - C_M*s - C_rot*s + J_M*s^2, C_rot*s - k_rot, 0, 0, 0];
Arow2 = [ A3 A4 0 A5 A6];
%Arow2 = [ C_rot*s - k_rot, k_rot - C_S*s - C_rot*s + J_S*s^2 + i^2*k_n - C_n*i^2*s, 0, i*k_n - C_n*i*s, C_n*i*s - i*k_n]
Arow3 = [0 0 A7 A8 0];
%Arow3 =[ 0, 0, k_B + k_ax - C_B*s - C_ax*s + M_B*s^2, C_ax*s - k_ax, 0]
Arow4 = [0 A9 A10 A11 A12]
% Arow4 = [ 0, i*k_n - C_n*i*s, C_ax*s - k_ax, k_ax + k_n - C_ax*s - C_n*s + M_S*s^2, C_n*s - k_n]
Arow5 = [0 A13 0 A14 A15]
%Arow5 = [ 0, C_n*i*s - i*k_n, 0, C_n*s - k_n, k_n - C_g*s - C_n*s + M_T*s^2]
A = [Arow1; Arow2; Arow3; Arow4; Arow5]
Answer = inv(A)
I am getting the following message after running the above code: "Output truncated. Text exceeds maximum line length for Command Window display."
Is there any other method to obtain the inverse of the above 5 by 5 matrix on Matlab?
Would appreciate the help. Thanks so much!

回答 (1 件)

Steven Lord
Steven Lord 2019 年 10 月 11 日
The answer, written out as text, is about 731,000 characters long.
>> length(char(Answer))
ans =
731073
A quick Google search yielded the rule of thumb that an average page contains about 3,000 characters. So your expression, if printed as a book, would be a little longer than the original UK printing of the first Harry Potter novel at about 243 pages. Even calling simplify on the answer doesn't shorten it that much; it's down to around 707,000 characters (about 235 pages.)
What do you want to actually do with this result? To substitute values into that expression, use subs. I tried substituting 1 for each of the symbolic variables individually, but the results were still really long. Substituting s = 1 had the largest impact, decreasing the length of the answer to about 629,000.
  2 件のコメント
Syeda Nadiah Nahri
Syeda Nadiah Nahri 2019 年 10 月 11 日
Dear Sir,
I need to first obtain the inverse matrix, and then obtain the relation between X_T(s) and T_M,
where, X_T(s) is handle position of my project i.e. the output.
T_M is the torque from DC motor fed as input to the system.
Untitled1.png
Steven Lord
Steven Lord 2019 年 10 月 11 日
You're trying to find the result of multiplying the inverse by a vector? In that case, don't use inv. Use the backslash operator (\) to solve A*x = b for x. [I assume by T_M in your picture you mean the symbolic variable M_T used in constructing your A matrix.]
V = A\[M_T; 0; 0; 0 ;0];
sol5 = V(5);
The expression sol5 is still pretty long, at a little over 27,000 characters or about 9 pages. But that's a lot better than 700,000+. pretty printing sol5 still requires some scrolling to see the whole thing, but you can see the whole thing. It also makes an impressively wide line of output when I ran this code in a Live Script in the Live Editor.

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

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox Supported Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by