% Example ID3.2 Illustrate properties of least-square estimate clc;echo on % Copyright 1996, Babu Joseph, Washington University in St.Louis % % This program illustrates what happens when there is not sufficient % excitation in the input signal % % First create some data by exciting a process % We will use a first order process % with gain 1 and time constant 5 num=[1];den=[5 1 ]; [numd,dend]=c2dm(num,den,1,'zoh'); % Define input as a random binary sequence t=0:1:10;u=0.1*ones(10,1); y=dlsim(numd,dend,u) +randn(10,1); % idplot([y u]); % Now generate the matrices for least square estimation of parameters % A=[-y(1:9) u(1:9)];b=y(2:10); % % The estimated coefficients of the transfer function are % x=A\b % % The following are the actual coefficients % xactual=[ dend(2) numd(2)]' % % Computed coefficients can be compared to actual coefficients % e=b-A*x;norm(e) mean(e) cond(A) % accuracy of the parameters are given by var=inv(A'*A)*1.0 % where we have used the fact that the variance of the noise is 1 % the diagonal elements of var gives the variance in first and second parameter % idplot([y u])