Two Quadratics are equal find K1 and K2 cancel out X
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
So I am coding something that will include two variables that are taking place of constants in a quadratic equation. We have a quadratic that is equal to the first equation so we can solve it by hand but I want to verify my numbers. However the solutions for K1 and K2 keep getting messed up by the x value (which in this code is deemed l) which should cancel out.
A =[1 -1; 0 0];
B = [0; 1];
MC = ctrb(A,B); %Gives controllability matrix
det (MC) %Not zero so is controllable
syms K1 K2 l
Atil = A-B*[K1 K2]
lambda = [l 0;0 l] ;
opt1 = det(lambda-Atil) % quadratic with K1 and K2 values
opt2 = l^2+1.5*l+0.5 %set quadratic
solve (opt1==opt2,K1,K2)
as you can see both can be put into the form of l^2+number*l+number so you should be able to take each section before the l to set it equal but I am not sure how to set that up correclty in matlab without individually manually making each section a variable anyone know an automated way for it?
0 Commenti
Risposta accettata
VBBV
il 5 Mar 2023
Modificato: VBBV
il 5 Mar 2023
A =[1 -1; 0 0];
B = [0; 1];
MC = ctrb(A,B); %Gives controllability matrix
det (MC) %Not zero so is controllable
syms K1 K2 l
Atil = A-B*[K1 K2]
lambda = [l 0;0 l] ;
opt1 = det(lambda-Atil) % quadratic with K1 and K2 values
opt1 = collect(opt1) % you can now equate the like terms of opt1 and opt2 and solve for K1 and K2
opt2 = l^2+1.5*l+0.5 %set quadratic
Sol = solve (opt1==opt2,[l,K1,K2])
Sol.l
Sol.K1
Sol.K2
sol = solve(opt1 == opt2,l)
Use collect to rearrange the equation
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Quadratic Programming and Cone Programming in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!