% B-spline Tutorial % by Ashish Myles (marcianx@gmail.com) % plot_spline(spline [, flags, [, color]] ) % flag: % bit 0 - if 1, plot in full range % bit 1 - if 1, then use a single color (black) % color: % color in which to plot the spline % (if exists, overrides bit 1's effect above) % function plot_spline(sp, varargin) hold on; flag = 0; if nargin > 1 flag = varargin{1}; end range = ( sp.order ):( length(sp.knots)-sp.order+1 ); if bitand(flag, 1) range = 1:length(sp.knots); end c = ['b', 'g', 'm', 'c']; if bitand(flag, 2) c = ['k']; end if nargin > 2 c = varargin{2}; end uknots = unique(sp.knots(range)); for i = 2:length(uknots) fnplt( sp, [uknots(i-1), uknots(i)], c(mod(i-1,length(c))+1) ); end hold off;