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
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 CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by