I am working on duct simulation with control theory
i have code but for estimator gain i am getting error
in the last line with lqe command i am trying to find estimator gain but it gives me error as following
Error using lqe (line 52)
Q must be square with as many columns as G.
Error in augmentedmode0 (line 76)
[L,P,E]= lqe(Aaug,Gaug,Caug,Qe,Re);
**********my code is ************
clear all ;
clc; close all;
Nmod = 0;
L = 1.2;
K = 0.051;
zi = 0.315;
zm = 0.775;
c = 340 ;
roh = 1.225;
S = 1;
eta =1 ;
betan = -Nmod*pi/L;
alfa = 1/(2*L)*log((1-K)/(1+K));
%******duct model for mode 0 **********
A0r = c*alfa;
A0i = c*eta;
G0 = -1 /(2*c*L*roh);
B0r = cos(eta*zi)*sinh(alfa*zi)/(2*c*L*roh*S);
B0i = sin(eta*zi)*cosh(alfa*zi)/(2*c*L*roh*S);
C0r = -2*roh*c^2*cos(eta*zm)*sinh(alfa*zm);
C0i = -2*roh*c^2*sin(eta*zm)*cosh(alfa*zm);
A0n = [A0r -A0i;A0i A0r]
B0n = [B0r;B0i]
G0n = [G0;0]
C0n = [C0r;C0i]'
%*******internal model*********** Ai1 = [0 1;-100^2 0]
Bi1 = [0;100^2]
Ci1 = [1 0]
%**********augmented mode0************
Aaug = [A0n B0n*Ci1;zeros(2) Ai1]
Baug = [zeros(2,1);Bi1]
Gaug = [G0n;zeros(2,1)]
Caug = [C0n zeros(1,2)]
Daug = 0
%************controller*********
Rc =1
q=60;
Qc = Caug'*q*Caug
[Kc,S,E] = lqr(Aaug,Baug,Qc,Rc);
%*************kalman gain*********
Re = 1;
qe1 = 0.01;
qe2 = 10^6;
Qe = qe1*Gaug*Gaug'+ qe2*Baug*Baug';
[L,P,E]= lqe(Aaug,Gaug,Caug,Qe,Re);