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
古いコメントを表示
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)) ;
採用された回答
その他の回答 (2 件)
Star Strider
2014 年 11 月 12 日
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
2014 年 11 月 13 日
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)
カテゴリ
ヘルプ センター および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!