dim = 65;
in = 10;
out = 65;
T = 2000;
A = zeros(dim);
B = zeros(dim,in);
C = zeros(out,dim);

A = A+diag(ones(dim,1))+diag(ones(dim-1,1),1)+diag(rand(dim-1,1),-1)
A = A./max(eig(A))./1.005;
eig(A)

C = eye(dim)

B = rand(dim,in)

0
gen = zpk([.2+.01*i .2-.01*i],[.4+.0025*i .4-.0025*i -.8+.005*i -.8-.005*i],1,1);
pzmap(gen)
u = [];
for k = 1:in
    u = [u; lsim(gen,randn(1,T),1:T)'];
end
plot(u')

s = ss(A,B,C,0,1)
0.1*randn(size(u))
y = lsim(s,u,1:T)

plot(y)

d = iddata(y,u')

s2 = n4sid(d,'Cov','none')

trace(s2.A)
trace(s.A)

y2 = lsim(s2,u,1:T)

plot(y-y2)
