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일
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

댓글을 달려면 로그인하십시오.

카테고리

질문:

2022년 3월 16일

댓글:

2022년 3월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by