The length of the initial condition X0 must match the number of states.
9 ビュー (過去 30 日間)
古いコメントを表示
hello everyone i cant seem to figure out what the problem with my code. it keeps giving me an error regarding the initial state. any help would be appreciated.
thanks!
here is my code.
A= [0 1 0; 0 0 1; -52 -30 -4];
B = [0;0;1];
C = [20 1 0];
D = [0];
% compute open loop state space
sys_OL = ss(A,B,C,D);
% scaling the B matrix
w = -C/A*B;
% open loop state space with scaled input
sys_OL2 = ss(A, B/w, C, D);
p0 = 5;
Ts = 2;
term = pi^2 +log(p0/100)^2;
zeta = abs(log(p0/100))/sqrt(term);
wn = 4 /Ts/zeta;
beta = sqrt(1-zeta^2);
p3 = 10 * zeta *wn
eigDes = [-zeta*wn+j*wn*beta -zeta*wn-j*wn*beta -p3 -20+i]
% compute the close loop
Ae= [0 1 0 0; 0 0 1 0; -52 -30 -4 0; -20 -1 0 0];
Be = [0;0;1; 0];
Ce = [20 1 0 0];
De = [0];
Br = [0;0;0;1]
Ke = acker(Ae, Be,eigDes) % gain matrix
sys_Cl = ss(Ae - Be*Ke, Br ,Ce,De) %transfer function of close loop
t = 0:0.001:5;
u = ones(size(t));
x0 = [0.01; 0; 0; 0];
x0hat = [0; 0; 0; 0 ];
yOL = lsim(sys_OL2, u, t, x0);
yCl = lsim(sys_Cl, u, t, [x0; x0hat]);
4 件のコメント
Johannes James
2021 年 3 月 14 日
It's very bad form to just say "i figured it out" and not exaplin what the solution was. Others coming here following search engine hits, looking for solutions, encounter your useless comment and absence of solution. If you bothered to post, concludet the matter with the solution!
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!