%********************************************************************* %Csci 2031 %Assignment 6 %Problem 4 %Basic B-Spline properties %********************************************************************* function[]= problem4() for i=0:1:4 a1=bSpline(3,0,i);%orig---Part A a2=bSplineDeriv(3,0,i);%deriv---Part B fprintf(' B(3,0,i) = %i \t(deriv)B(3,0,i) = %f\n' ,a1, a2); end end %************************************************************************* %Recursive function to determine the B-spline of degree k %************************************************************************* function[bVal] = bSpline(k,i,x) if(k==0) if(i<= x && x <(i+1) ) bVal = 1; else bVal = 0; end else bVal = ( (x-i)./k)* bSpline(k-1, i, x) + (( (i+k+1)-x)./ ((i+k+1) - (i+1)))*bSpline(k-1, i+1, x); end end %End bSpline %************************************************************************* %Recursive function to determine the derivative of a B-spline of degree k %************************************************************************* function [bVal]= bSplineDeriv(k,i,x) if(k==0) if(i<=x && x <(i+1)) bVal=1; else bVal=0; end else bVal = (k./k)*bSplineDeriv(k-1, i, x) - (k./k)*bSplineDeriv(k-1, i+1, x); end end %End bSplineDeriv