X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fsplines-1.0.7%2Ffnplt.m;fp=octave_packages%2Fsplines-1.0.7%2Ffnplt.m;h=441770be260b35440cf11c66e77fff76daf258bd;hp=0000000000000000000000000000000000000000;hb=f5f7a74bd8a4900f0b797da6783be80e11a68d86;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/splines-1.0.7/fnplt.m b/octave_packages/splines-1.0.7/fnplt.m new file mode 100644 index 0000000..441770b --- /dev/null +++ b/octave_packages/splines-1.0.7/fnplt.m @@ -0,0 +1,60 @@ +## Copyright (C) 2000 Kai Habel +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see . + +## -*- texinfo -*- +## @deftypefn {Function File} { } fnplt (@var{pp}, '@var{plt}') +## plots spline +## +## @seealso{ppval, spline, csape} +## @end deftypefn + +## Author: Kai Habel +## Date: 3. dec 2000 +## 2001-02-19 Paul Kienzle +## * use pp.x rather than just x in linspace; add plt parameter +## * return points instead of plotting them if desired +## * also plot control points +## * added demo + +function [x, y] = fnplt (pp, plt) + + if (nargin < 1 || nargin > 2) + usage ("[x, y] = fnplt (pp [, plotstring])"); + endif + if (nargin < 2) + plt = "r;;"; + endif + xi = linspace(min(pp.x),max(pp.x),256)'; + pts = ppval(pp,xi); + if nargout == 2 + x = xi; + y = pts; + elseif nargout == 1 + x = [xi, pts]; + else + plot(xi,pts,plt,pp.x,ppval(pp,pp.x),"bx;;"); + endif + +endfunction + +%!demo +%! x = [ 0; sort(rand(25,1)); 1 ]; +%! pp = csape (x, sin (2*pi*3*x), 'periodic'); +%! axis([0,1,-2,2]); +%! title('Periodic spline reconstruction of randomly sampled sine'); +%! fnplt (pp,'r;reconstruction;'); +%! t=linspace(0,1,100); y=sin(2*pi*3*t); +%! hold on; plot(t,y,'g;ideal;'); hold off; +%! axis; title("");