1## Copyright (C) 2000 Kai Habel 2## 3## This program is free software; you can redistribute it and/or modify it under 4## the terms of the GNU General Public License as published by the Free Software 5## Foundation; either version 3 of the License, or (at your option) any later 6## version. 7## 8## This program is distributed in the hope that it will be useful, but WITHOUT 9## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11## details. 12## 13## You should have received a copy of the GNU General Public License along with 14## this program; if not, see <http://www.gnu.org/licenses/>. 15 16## -*- texinfo -*- 17## @deftypefn {Function File} { } fnplt (@var{pp}, '@var{plt}') 18## plots spline 19## 20## @seealso{ppval, spline, csape} 21## @end deftypefn 22 23## Author: Kai Habel <kai.habel@gmx.de> 24## Date: 3. dec 2000 25## 2001-02-19 Paul Kienzle 26## * use pp.x rather than just x in linspace; add plt parameter 27## * return points instead of plotting them if desired 28## * also plot control points 29## * added demo 30 31function [x, y] = fnplt (pp, plt) 32 33 if (nargin < 1 || nargin > 2) 34 print_usage; 35 endif 36 if (nargin < 2) 37 plt = "r;;"; 38 endif 39 xi = linspace(min(pp.breaks),max(pp.breaks),256)'; 40 pts = ppval(pp,xi); 41 if nargout == 2 42 x = xi; 43 y = pts; 44 elseif nargout == 1 45 x = [xi, pts]; 46 else 47 plot(xi,pts,plt,pp.breaks,ppval(pp,pp.breaks),"bx;;"); 48 endif 49 50endfunction 51 52%!demo 53%! x = [ 0; sort(rand(25,1)); 1 ]; 54%! pp = csape (x, sin (2*pi*3*x), 'periodic'); 55%! axis([0,1,-2,2]); 56%! title('Periodic spline reconstruction of randomly sampled sine'); 57%! fnplt (pp,'r;reconstruction;'); 58%! t=linspace(0,1,100); y=sin(2*pi*3*t); 59%! hold on; plot(t,y,'g;ideal;'); hold off; 60%! axis; title(""); 61