📄 demo.m
字号:
% TEST the functions in the toolbox.% ---- Simulation parametern = 5; m = 2; p = 3;l = ceil(n/p);lmax = l;nmax = n;delta = nmax+1;s = 0; % additive noise standard deviationT = 500; % time horizonL = 50; % # of samples to be computed from the impulse response% ---- Simulate impulse responsesys0 = drss_(n,p,m);h0 = impulse(sys0,L);if (m == 1) if (p > 1) % transform the TxM H0 in PxMxT format h0s = h0; h0 = zeros(p,m,L); for t = 1:L h0(:,:,t) = h0s(t,:)'; end clear h0s endelse h0 = shiftdim(h0,1);endht = randn(size(h0));h = h0 + s * ht;% ---- Simulate input/output datau0 = rand(T,m);x0 = rand(n,1);y0 = lsim(sys0,u0,[],x0);ut = randn(T,m);yt = randn(T,p);u = u0 + s * ut;y = y0 + s * yt;w = [u y];% ---- Apply various (combinations of) functions% UY2Hhh = uy2h(u,y,lmax,delta,L);fprintf('%24s: error = %f\n', 'uy2h', norm(h0(:)-hh(:)))% UY2HBLKhhblk = uy2hblk(u,y,lmax,L);fprintf('%24s: error = %f\n', 'uy2hblk', norm(h0(:)-hhblk(:)))% UY2HY0[hh,y0h] = uy2hy0(u,y,lmax,delta,L);y0h_ = uy2y0(u,y,lmax,delta,L);fprintf('%24s: error_h = %f\n', 'uy2hy0', norm(h0(:)-hh(:)))fprintf('%24s: error_y0 = %f\n', 'uy2hy0', norm(y0h(:)-y0h(:)))% H2SSsysh = h2ss(h);fprintf('%24s: error = %f\n', 'h2ss', norm(sys0-sysh,'inf'))% UY2SSMRsysh = uy2ssmr(u,y,lmax+1,n);fprintf('%24s: error = %f\n', 'uy2ssmr', norm(sys0-sysh,'inf'))% UY2SSVDsysh = uy2ssvd(u,y,lmax+1);fprintf('%24s: error = %f\n', 'uy2ssvd', norm(sys0-sysh,'inf'))% UY2H -> H2SSsysh = uy2h2ss(u,y,lmax,delta);fprintf('%24s: error = %f\n', 'uy2h2ss', norm(sys0-sysh,'inf'))% UY2Y0 -> Y02OX -> UYO2SS sysh = uy2o2ss(u,y,lmax,delta);fprintf('%24s: error = %f\n', 'uy2o2ss', norm(sys0-sysh,'inf'))% UY2Y0 -> Y02OX -> UYX2SSsysh = uy2x2ss(u,y,lmax,delta);fprintf('%24s: error = %f\n', 'uy2x2ss', norm(sys0-sysh,'inf'))% UY2H -> H2OX -> UYO2SS sysh = uy2h2o2ss(u,y,lmax,delta);fprintf('%24s: error = %f\n', 'uy2h2o2ss', norm(sys0-sysh,'inf'))% UY2HY0 -> HY02OXBAL -> UYX2SSsysh = uy2ssbal(u,y,lmax,delta);fprintf('%24s: error = %f\n', 'uy2ssbal', norm(sys0-sysh,'inf'))return% W2R -> R2PQ -> PQ2SSsysh = w2r2ss([u,y],lmax);fprintf('%24s: error = %f\n', 'w2r2ss', norm(sys0-sysh,'inf'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -