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
Ältere Kommentare anzeigen
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)) ;
Akzeptierte Antwort
Weitere Antworten (2)
Star Strider
am 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
am 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)
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!