I need help solving the equation that I am to create with a variable and every time I try to solve it seems to not work
Show older comments
So here is the code that I have which wont work.I want h to be a variable and then the matrix K1 should be a matrix with the variable in it. Then to solve for h you should take the determinant of K1=0 which should yield two answers for h. I then would like to display those two answers. Can anyone help me out, it either says that I haven't defined h and then when I do matrix K1 becomes some weird value without h and the solve function which I read should work doesn't. Please let me know what im doing wrong. Thanks
h='h';
K1 = [(20-h),-10/sqrt(2);-10/sqrt(2),(30-h)];
lambda = solve( det(K1)==0 ,h );
disp(' Lambda 1 is'),disp(lambda(1)) ;
disp(' Lambda 2 is'),disp(lambda(2)) ;
Accepted Answer
More Answers (2)
Star Strider
on 12 Nov 2014
syms h
K1 = [(20-h),-10/sqrt(2);-10/sqrt(2),(30-h)];
lambda = solve(charpoly(K1,h))
produces:
lambda =
25/2 - (5*3^(1/2))/2
(5*3^(1/2))/2 + 25/2
William Rose
on 13 Nov 2014
You can just do what you originally posted, but with "syms h" added, as shown below. (You can use charpoly, as Star Strider said, but you don't have to):
>> syms h;
>> K1 = [(20-h),-10/sqrt(2);-10/sqrt(2),(30-h)];
>> solve(det(K1))
ans =
5*3^(1/2) + 25
25 - 5*3^(1/2)
Categories
Find more on Number Theory 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!