getf SCI/util/testexamples.sci reinit_for_test() %U=mopen('SCI/tests/automatic_tests/rtitr_data.ref','rb'); z = poly(0, 'z'); Num = 1 + z;Den = 1 + z;u = [1,2,3,4,5]; %ans = rtitr(Num, Den, u) - u; if load_ref('%ans') then bugmes();quit;end, //Other examples //siso //causal n1 = 1;d1 = poly([1,1], 'z', 'coeff');// y(j)=-y(j-1)+u(j-1) r1 = [0,1,0,1,0,1,0,1,0,1,0]; r = rtitr(n1, d1, ones(1, 10));%ans = norm(r1 - r, 1); if load_ref('%ans') then bugmes();quit;end, //hot restart r = rtitr(n1, d1, ones(1, 9), 1, 0);%ans = norm(r1(2:11) - r); if load_ref('%ans') then bugmes();quit;end, //non causal n2 = poly([1,1,1], 'z', 'coeff');d2 = d1;// y(j)=-y(j-1)+u(j-1)+u(j)+u(j+1) r2 = [2,1,2,1,2,1,2,1,2]; r = rtitr(n2, d2, ones(1, 10));%ans = norm(r - r2, 1); if load_ref('%ans') then bugmes();quit;end, //hot restart r = rtitr(n2, d2, ones(1, 9), 1, 2);%ans = norm(r2(2:9) - r, 1); if load_ref('%ans') then bugmes();quit;end, // //MIMO example //causal d1 = d1 * diag([1,0.5]);n1 = [1,3,1;2,4,1];r1 = [5;14] * r1; r = rtitr(n1, d1, ones(3, 10));%ans = norm(r1 - r, 1); if load_ref('%ans') then bugmes();quit;end, // r = rtitr(n1, d1, ones(3, 9), [1;1;1], [0;0]); %ans = norm(r1(:, 2:11) - r, 1); if load_ref('%ans') then bugmes();quit;end, //polynomial n1 (same ex.) n1(1, 1) = poly(1, 'z', 'c');r = rtitr(n1, d1, ones(3, 10));%ans = norm(r1 - r, 1); if load_ref('%ans') then bugmes();quit;end, // r = rtitr(n1, d1, ones(3, 9), [1;1;1], [0;0]); %ans = norm(r1(:, 2:11) - r, 1); if load_ref('%ans') then bugmes();quit;end, //non causal d2 = d1;n2 = n2 * n1;r2 = [5;14] * r2; r = rtitr(n2, d2, ones(3, 10));%ans = norm(r2 - r); if load_ref('%ans') then bugmes();quit;end, // r = rtitr(n2, d2, ones(3, 9), [1;1;1], [10;28]); %ans = norm(r2(:, 2:9) - r, 1); if load_ref('%ans') then bugmes();quit;end, // // State-space or transfer a = [0.21,0.63,0.56,0.23,0.31; 0.76,0.85,0.66,0.23,0.93; 0,0.69,0.73,0.22,0.21; 0.33,0.88,0.2,0.88,0.31; 0.67,0.07,0.54,0.65,0.36]; b = [0.29,0.5,0.92; 0.57,0.44,0.04; 0.48,0.27,0.48; 0.33,0.63,0.26; 0.59,0.41,0.41]; c = [0.28,0.78,0.11,0.15,0.84; 0.13,0.21,0.69,0.7,0.41]; d = [0.41,0.11,0.56; 0.88,0.2,0.59]; s = syslin('d', a, b, c, d); h = ss2tf(s);num = h('num');den = h('den');den = den(1, 1) * eye(2, 2); u = 1;u(3, 10) = 0;r3 = flts(u, s); r = rtitr(num, den, u);%ans = norm(r3 - r, 1); if load_ref('%ans') then bugmes();quit;end, xdel_run(winsid()); mclose(%U);