home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / POLYFUN.DI$ / MKPP.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  976 b   |  31 lines

  1. function pp=mkpp(breaks,coefs)
  2. %MKPP    Make piecewise polynomial.  
  3. %
  4. %      pp = mkpp(breaks,coefs)
  5. %
  6. %    puts together a pp function from the breaks and coefficients input or
  7. %    requested. The number  l  of polynomial pieces is determined as
  8. %      l := length(breaks)-1 .
  9. %    The  order  k  of the pp is obtained as
  10. %      k := length(coefs)/l ,
  11. %    and this ratio had better be an integer. 
  12. %
  13. %    See also UNMKPP, PPVAL, SPLINE.
  14.  
  15. %    Carl de Boor 7-2-86
  16. %    Revised 9-30-88 LS
  17. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  18.  
  19. if (nargin==0);
  20.    breaks=input('Give the (l+1)-vector of breaks  >');  
  21.    coefs=input('Give the (l by k) matrix of local pol. coefficients  >');
  22. end
  23.    coefs=coefs(:).';lk=length(coefs);l=length(breaks)-1;k=fix(lk/l);
  24. if (k<=0)|(l*k~=lk);
  25.    fprintf('The given number %.0f of polynomial pieces is incompatible',l)
  26.    fprintf(' with the total number %.0f of coefficients supplied!\n',lk)
  27.    pp=[];   
  28. else
  29.    pp=[l breaks(:)' k coefs];
  30. end
  31.