How to invert a matrix that has variables?
Show older comments
Hello everybody, I'm trying to invert a matrix in which every entry depends on the variable h. If I experiment in a general case and do:
syms h
A=[1*h (2-h)*3;(2-h)*3 0]
B=inv(A)
I am able to recieve the inverse matrix of A because it is a square symmetric matrix. However, in my specific case I have:
w=ones(2,1);
p=5;
x=w.^(1/p);
S=rand(1,2);
syms h
alpha=x+h*S';
w_alpha=alpha.^p;
K_total=sym(zeros(8));
C_1=rand(3);
C_1=(C_1+C_1')/2;
C_2=rand(3);
C_2=(C_2+C_2')/2;
C=w_alpha(1)*C_1+w_alpha(2)*C_2;
B=rand(3,8);
g_L_ele=[1 2 5 6 7 8 3 4];
K_total(g_L_ele,g_L_ele)=...
K_total(g_L_ele,g_L_ele)+...
B'*C*B;
K=vpa(K_total,2);
K=(K+K')/2;
inv(K)
Even though it's still a square symmetric matrix, that only depends on h, I can't get the inverse. Can anybody help me please? I have a final project due to tomorrow and this is the only part I'm missing in order to complete it.
2 Comments
John D'Errico
on 26 Jan 2018
K_total is undefined, although you have defined a variable named K_total_h. So of course your code must fail.
Note that reducing the matrix to 2 digits is pure insanity when trying to compute an inverse. Could that also be part of your problem? How can I know?
Ronaldinho Bato
on 26 Jan 2018
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!