The length of the initial condition X0 must match the number of states.
조회 수: 7 (최근 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에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!