finding variables in polynomial expressions

Hi, have an issue i cant solve with matlab, i wish to get matlab to solve this equation for k1 k2 and ke.
Have tried res = solve((a-b),[k1 k2 ke]) but does not give the results im looking for
clc
clear, close all;
syms s k1 k2 ke
A = [0 -83.33; 500 -10];
B = [166.67; 0];
C= [0 1];
K = [k1 k2];
A2 = [A-B*K B*ke; -C 0];
a = det(s*eye(3)-A2);
b = (s+1600)*(s^2+160*s+30790);
how i do it by hand

 採用された回答

Walter Roberson
Walter Roberson 2022 年 3 月 16 日

1 投票

syms s k1 k2 ke
A = [0 -83.33; 500 -10];
B = [166.67; 0];
C= [0 1];
K = [k1 k2];
A2 = [A-B*K B*ke; -C 0];
a = det(s*eye(3)-A2);
b = (s+1600)*(s^2+160*s+30790);
eqn = collect(a-b,s)
eqn = 
sol = solve(coeffs(eqn, s))
sol = struct with fields:
k1: 25000/2381 k2: 45525/16667 ke: 9852800/16667

1 件のコメント

fredrik s
fredrik s 2022 年 3 月 16 日
Excellent, just what i was looking for. Thanks alot :D

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

その他の回答 (1 件)

Torsten
Torsten 2022 年 3 月 16 日
編集済み: Torsten 2022 年 3 月 16 日

0 投票

A = [0 -83.33; 500 -10];
B = [166.67; 0];
C = [0 1];
K = @(k1,k2)[k1 k2];
A2 = @(k1,k2,ke) [A-B*K(k1,k2) B*ke; -C 0];
a = @(k1,k2,ke,s) det(s*eye(3)-A2(k1,k2,ke));
b = @(s)(s+1600)*(s^2+160*s+30790);
fun = @(k1,k2,ke)[a(k1,k2,ke,-1)-b(-1);a(k1,k2,ke,0)-b(0);a(k1,k2,ke,1)-b(1)];
sol = fsolve(@(k)fun(k(1),k(2),k(3)),[0;0;0]);
k1 = sol(1)
k2 = sol(2)
ke = sol(3)

1 件のコメント

fredrik s
fredrik s 2022 年 3 月 16 日
Thanks, works like a charm. Is it possible to solve with syms s k1 k2 ke, so the decleration @(k1,k2,ke)is avoided in order to easily expand to k1 k2 k3...kn

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

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by