%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% Homework #10.3 Code Fragment %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %On entry, variables "k, t, & a" must be provided %Assumes you provide routines: %[T, A] = KnotInsertion(k, t, a, x); %[Tstar, Astar] = ControlPolygon(k, t, a); %You will also need to include in your project the files: % CreateBk.m, CreateOmega.m, BSpline.m % which can be obtained from my webpage %%%%%%%%%%%%%%%%%%%%%%%%%%% % To experiment with other F's % can uncomment the following line %a = rand(1,length(t)-k); %initialization for knot insertions Count = 30; xrand = t(1) + (t(end)-t(1)) * rand(1,Count); %X-discretization for spline creation h = 0.01; figure(99) for i=1:Count %insert next random knot x = xrand(i); [t, a] = KnotInsertion(k, t, a, x); [Tstar, Astar] = ControlPolygon(k, t, a); %create the B-spline Bjk (k=4) [X, B4] = CreateBk(t,k,h); %create f=sum Aj * Bjk F = repmat(a, length(X), 1); F = F .* B4; f = sum(F'); %plot resulting spline (these should all = the same f!!) % and new control polygon plot(X, f, 'k', Tstar, Astar, 'm'); pause(0.2); end