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

  1. % CHEBDEM    Demonstrate the construction of a Chebyshev spline.
  2. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  3.                                      % latest change: September 28, 1990
  4. clg;clc;home;echo on
  5. % Try the construction of the Chebyshev spline  C_t(x)  as an example.
  6. % By definition, for given knot sequence  t in R^{n+k},  C_t  is the
  7. % unique element of  S_{t,k}  of max-norm 1  which maximally oscillates on
  8. % the interval  [t_k,t_{n+1}]  and is positive near  t_{n+1} . This means
  9. % that there is a unique strictly increasing  tau in R^n  so that the 
  10. % function  C in S_{k,t}  given by  C(tau(i))=(-)^{n-i} , all  i , has
  11. % max-norm 1 on  [t_k,t_{n+1}] . This implies that  tau(1) = t_k , 
  12. %  tau(n) = t_{n+1} , and that  t_i < tau(i) < t_{k+i} , all i .  In fact,
  13. %  t_{i+1} \le tau(i) \le t_{i+k-1} , all i . This brings up the point
  14. % that the knot sequence is assumed to make such an inequality possible,
  15. % i.e., the elements of  S_{k,t}  are assumed to be continuous.
  16. %
  17. %  In short, the Chebyshev spline  C  looks just like the Chebyshev poly-
  18. % nomial.  It performs similar functions. For example, its extrema  tau
  19. % are particularly good points to interpolate at from  S_{k,t}  since the
  20. % norm of the resulting projector is about as small as can be.
  21. %
  22.      pause;                          % touch any key to continue
  23.  
  24. %   In this example, we try to construct  C  for given knot sequence  t .
  25. %
  26. %   We deal with cubic splines, i.e., with order
  27. k = 4;
  28. %   and use the break sequence
  29. breaks = [0 1 1.1 3 5 5.5 7 7.1 7.2 8]; lb=length(breaks);
  30.  
  31.      pause;                          % touch any key to continue
  32.  
  33. % and use simple interior knots, i.e., use the knot sequence
  34. t = breaks([ones(1,k) 2:lb-1  lb*ones(1,k)])
  35.  
  36.      pause;                          % touch any key to continue
  37.  
  38. % thus getting a spline space of dimension
  39. n = length(t)-k
  40.  
  41.      pause;                          % touch any key to continue
  42.  
  43. %   As our initial guess for the  tau , we use the knot averages  
  44. %
  45. %           tau(i) = (t_{i+1} + ... + t_{i+k-1})/(k-1)
  46. %
  47. % recommended as good interpolation point choices.
  48.  
  49.      pause;                          % touch any key to continue
  50.  
  51. tau=aveknt(t,k)
  52. echo off
  53. e=zcheck(tau-[0 10 21 51 91 135 175 196 213 223 232 240]/30); echo on
  54.  
  55.      pause;                          % touch any key to continue
  56.  
  57. %  We plot the resulting first approximation to  C :
  58.  
  59. b=(-ones(1,n)).^[n-1:-1:0];
  60. c = spapi(t,tau,b);
  61. echo off;
  62. e=zcheck(b-fnval(c,tau));echo on;
  63. fnplt(c,'-.');pause
  64. grid;pause
  65. hold on;
  66.  
  67. chebloop
  68.