home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 5.ddi / SPLINES.DI$ / SPMAK.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.2 KB  |  38 lines

  1. function spline=spmak(knots,coefs)
  2. % SPMAK    Make a spline function.
  3. %
  4. %       spline = spmak(knots,coefs)
  5. %
  6. %  puts together a spline from the knots and coefficients input or
  7. %  requested.  coefs  is expected in the form  coefs(d,n)  with  d  the number
  8. %  of components (usually 1,2 or 3) in each of the  n  spline coefficient 
  9. %  supplied.  The  order of the spline is inferred as  k := length(knots) - n .
  10.  
  11. % Carl de Boor / latest change: December 9, 1989
  12. % Carl de Boor / latest change: February 4, 1991(to disallow the check for d>n)
  13. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  14.    
  15. if (nargin==0);
  16.    knots=input('Give the vector of knots  >');  
  17.    coefs=input('Give the array of B-spline coefficients  >');    
  18. end
  19. [d,n]=size(coefs);
  20. if (d==0),
  21.    error('The coefficient sequence is empty!')
  22. end
  23. %if (d>n), 
  24. %   coefs=coefs';[d,n]=size(coefs);
  25. %   fprintf('spmak took the rows (rather than the columns) of the input \n')
  26. %   fprintf('coefficient array to be the coefficients.\n')
  27. %   end
  28.  
  29. k=length(knots)-n;
  30. if (k<=0),
  31.    error('There should be more knots than coefficients!')
  32. end
  33. if (~isempty(find(diff(knots)<0))),
  34.    error('The knot sequence should be nondecreasing!')
  35. end
  36.  
  37. spline=[11 d n coefs(:)' k knots(:)'];
  38.