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

  1. function y=idsim(ue,th)
  2. %IDSIM  simulates a given system
  3. %
  4. %    Y = idsim(Z,TH)
  5. %
  6. %    TH: contains the parameters of the model in the format described by 
  7. %    HELP THETA.
  8. %
  9. %    Z: the input-noise data Z=[u e]. For multi-variable systems
  10. %    u=[u1 u2 ... un e1 e2 .. ep], with ui and ei being column vectors. 
  11. %    The number of noise sources should equal the number of outputs. If
  12. %    the e-vector(matrix) is omitted, a noise-free simulation is obtained.
  13. %    The noise contribution is scaled by the variance information con-
  14. %    tained in TH.
  15.  
  16. %    L. Ljung 10-1-86, 10-2-90
  17. %    Copyright (c) 1986-90 by the MathWorks, Inc.
  18. %    All Rights Reserved.
  19.  
  20. if isthss(th),eval('y=idsimss(ue,th);'),return,end
  21. [N,nue]=size(ue);
  22. if nue>N, error(' The data should be organized in columns!'),return,end
  23.  
  24. [a,b,c,d,f]=th2poly(th);
  25. nu=th(1,3);
  26. LAM=th(1,1);
  27. T=gett(th);
  28. if T<0,error('This is a continuous time model of input-output type. Please sample it (using thc2thd) before applying idsim!'),end
  29. y=zeros(N,1);
  30. for k=1:nu
  31.    y=y + filter(b(k,:),f(k,:),ue(:,k));
  32. end
  33.  
  34. if nue>nu, y=y+sqrt(LAM)*filter(c,d,ue(:,nu+1));end
  35.  
  36. y=filter([1],a,y);
  37.