home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 9.ddi / IDENT.DI$ / CS1.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  5.7 KB  |  210 lines

  1. if ~exist('decimate'),error('Sorry, this test case requires the Signal Processing Toolbox'),end
  2. echo on,clc
  3. %CASE STUDY NUMBER 1 : A GLASS TUBE DRAWING FACTORY
  4. %
  5. % In this Case Study we shall study data from a glass tube factory. The
  6. % experiments and the data are discussed in
  7. %
  8. % V. Wertz, G. Bastin and M. Heet: Identification of a glass tube
  9. % drawing bench. Proc. of the 10th IFAC Congress, Vol 10, pp 334-339
  10. % Paper number 14.5-5-2. Munich August 1987.
  11. %
  12. % The the output of the process is the thickness and the diameter of
  13. % the manufactured tube. The inputs are the air-pressure inside the
  14. % tube and the drawing speed.
  15. %
  16. % We shall in this tutorial study the process from the input speed
  17. % to the output thickness.
  18. %
  19. load thispe25.mat
  20. % First we look at the data. We split it into two halves, one for
  21. % estimation and one for validation:
  22. %
  23.  
  24. ze=thispe25(1001:1500,:);
  25. zv=thispe25(1501:2000,:);pause
  26. idplot(ze),pause
  27. % A close-up:
  28. pause
  29. idplot(ze,101:200),pause
  30. % Let us remove the mean values:
  31.  
  32. ze=dtrend(ze);
  33. zv=dtrend(zv);
  34.  
  35. % The sampling interval of the data is one second. We may perhaps
  36. % detect some rather high frequencies in the output. Let us therefore
  37. % first compute the input and output spectra:
  38.  
  39. sy=spa(ze(:,1));
  40. su=spa(ze(:,2));
  41. pause  % Red/solid is output spectrum and green/dashed is input
  42.  
  43. bodeplot([sy su])
  44. grid,pause
  45.  
  46. % We may note that the input has very little relative energy above 1 rad/sec
  47. % while a substantial part of the output's energy comes from frquencies above
  48. % 1 rad/sec. There are thus some high frequency disturbancies that may cause
  49. % some problem for the model building.
  50.  
  51. % We first compute the impulse response, using part of the data:
  52.  
  53. [ir,dum,cl]=cra(ze); pause
  54. plot(0:19,ir,'g',0:19,cl*ones(1,20),'-.r',0:19,-cl*ones(1,20),'-.r')
  55. title('The impulse response with confidence limits'),pause
  56.  
  57. % We see a quite substantial delay of about 12 samples in the impulse response.
  58.  
  59. % We also as a preliminary test compute the spectral analysis estimate:
  60.  
  61. [gs,phiv]=spa(ze);
  62. pause
  63. bodeplot(gs,1),pause
  64.  
  65. % We note, among other things, that the high frequency behavior is quite
  66. % uncertain.
  67.  
  68. % Let us do a quick check if we can pick up good dynamics by just computing
  69. % a fourth order ARX model using the estimation data and simulate that
  70. % model using the validation data. We know that the delay is about 12:
  71. pause  % Press a key to continue
  72.  
  73. m1=arx(ze,[4 4 12]);
  74. compare(zv,m1);pause
  75.  
  76. % A close up:
  77. pause
  78. compare(zv,m1,inf,101:200);pause
  79.  
  80. %
  81. % There are clear difficulties to deal with the high frequency components
  82. % of the output. That in conjunction with the long delay suggests that we
  83. % decimate the data  by four (i.e. low-pass filter it and pick every fourth 
  84. % value):
  85.  
  86. zd(:,1)=decimate(dtrend(thispe25(:,1)),4);
  87. zd(:,2)=decimate(dtrend(thispe25(:,2)),4);
  88.  
  89. zde=zd(1:500,:);
  90. zdv=zd(501:length(zd),:);
  91. pause
  92.  
  93. % Let us find a good structure for the decimated data.
  94.  
  95. % First compute the impulse response:
  96.  
  97. [ird,dum,cl]=cra(zde); pause
  98. plot(0:19,ird,'g',0:19,cl*ones(1,20),'-.r',0:19,-cl*ones(1,20),'-.r')
  99. title('The impulse response for decimated data with confidence limits'),pause
  100.  
  101. % We see that the delay is about 3 (which is consistent with what we saw
  102. % above.
  103.  
  104. % What does the "quick start" give?
  105.  
  106. pause
  107. compare(zdv,arx(zde,[4 4 3]));pause
  108.  
  109. % Seems much better that for the undecimated data. Let's go on to find
  110. % a good model structure. First we look for the delay:
  111.  
  112.  
  113. V = arxstruc(zde,zdv,struc(2,2,1:30));
  114. nn=selstruc(V,0)
  115.  
  116. % Then we test several different orders with and around this delay:
  117.  
  118. V = arxstruc(zde,zdv,struc(1:5,1:5,nn(3)-1:nn(3)+1));
  119.  
  120. % Make your own choice of orders based on the figure to follow.
  121. % (The "model quality" comments to be made below refer to the default choice)
  122.  
  123. pause,
  124. nn=selstruc(V)
  125.  
  126. % Let's compute and check the model for whatever model you just preferred:
  127.  
  128. m2=arx(zde,nn);
  129. m2=sett(m2,4); % The sampling interval
  130. pause
  131. compare(zdv,m2,inf,21:150);pause
  132.  
  133. % This seems reasonably good!
  134.  
  135. % We may also compare the bodeplots of the model m1 and m2:
  136.  
  137. g1=th2ff(m1);
  138. g2=th2ff(m2);
  139. pause
  140. bodeplot([g1 g2]),pause
  141.  
  142. % We see that the two models agree well up to the Nyquist frequency of
  143. % the slower sampled data.
  144.  
  145. % Let's test the residuals:
  146. pause
  147. resid(zdv,m2);pause
  148.  
  149. % This seems OK.
  150.  
  151. % What does the pole-zero diagram tell us?
  152.  
  153. zpplot(th2zp(m2),3,[],2),pause
  154.  
  155. % No clear indication of pole-zero cancellations!
  156.  
  157.  
  158. % Let us however also check if we can do better by modeling the noise
  159. % separately in a Box-Jenkins model:
  160.  
  161. mb=bj(zde,[nn(2) 2 2 nn(1) nn(3)]);
  162. mb=sett(mb,4); % The sampling interval
  163.  
  164. % Is this better than the ARX-model in simulation ?
  165. % (press key)
  166. pause
  167. clf reset
  168. subplot(211)
  169. compare(zdv,m2);
  170. subplot(212)
  171. compare(zdv,mb);pause
  172.  
  173. % The Box-Jenkins model is thus capable of describing the validation 
  174. % data set somewhat better. How about the Bode plots?
  175.  
  176. gb=th2ff(mb);
  177. pause
  178. clf reset
  179. bodeplot([g2 gb]),pause
  180.  
  181. % The models agree quite well, apart from the funny twist in the BJ model.
  182. % This twist, however, seems to have some physical relevance, since we
  183. % get better simulations in the latter case.
  184. % Finally we may compare the FPE:s of the two models:
  185.  
  186. [m2(2,1) mb(2,1)]
  187.  
  188. % To summarize: After decimation it is quite possible to build simple models
  189. % that are capable of reproducing the validation set in a good manner.
  190.  
  191. % We can however do quite well with a much simpler model; a [1 1 3] ARX model:
  192.  
  193. m3=arx(zde,[1 1 3]);
  194.  
  195. % Simulation:
  196.  
  197. pause
  198. clf reset,subplot(211),compare(zdv,m3);subplot(212),compare(zdv,mb);pause
  199.  
  200. % 5-step ahead prediction:
  201.  
  202. pause
  203. clf,subplot(211),compare(zdv,m3,5);subplot(212),compare(zdv,mb,5);pause
  204.  
  205. pause
  206. echo off
  207.  
  208.  
  209.