How to code Cox de Boor algorithm to generate basis functions for open non uniform vector?

9 visualizzazioni (ultimi 30 giorni)
Hi, I am beginner to Matlab and I am currently trying to code Cox de Boor algorithm to generate basis functions for any order the formula is given here for your reference http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-property.html#reduce-no-non-zero
I have tried to write a code and I have attached here:
function[N]=basis(n,p,u,t)
i = 1:n+p+1;
p = 0:n;
t = t(:).'; % knot sequence
N(i,p)=zeros(1000);
u=zeros(1000);
if (p = 0)
while (u>=u(i)) && (u<u(i+1))
N(i,p)=0;
end
else
N(i,p)=0;
end
end
if (p>0)
for i=1:n+p+1
N(i,p)=(u-u(i)/u(i+p)-u(i))*N(i,p-1)+...
(u(i+p+1)-u/u(i+p+1)-u(i+1))*N(i+1,p-1);
end
end
plot(N(i,p),u)
Kindly help me fix the errors

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by