t=[0,1,2,3];
xx=linspace(-5,5);
plot(xx,BSplineEval(1,1,t,xx))
plot(xx,BSplineEval(1,1,t,xx),'o')
BSplineEval(1,1,t,1)
ans =
0
plot(xx,BSplineEval(2,1,t,xx),'o')
plot(xx,BSplineEval(3,1,t,xx),'o')
plot(xx,BSplineEval(4,1,t,xx),'o')
??? Attempted to access t(5); index out of bounds because
numel(t)=4.
Error in ==> BSplineEval at 4
yy(t(j) <= xx & xx < t(j+1)) = 1;
t
t =
0 1 2 3
plot(xx,BSplineEval(3,1,t,xx),'o')
BSplineEval(3,1,t,3)
ans =
1
BSplineEval(,1,t,3)
??? BSplineEval(,1,t,3)
|
Error: Expression or statement is incorrect--possibly
unbalanced (, {, or [.
BSplineEval(1,1,t,3)
ans =
0
BSplineEval(2,1,t,3)
ans =
0
BSplineEval(3,1,t,3)
ans =
0
BSplineEval(4,1,t,3)
??? Attempted to access t(5); index out of bounds because
numel(t)=4.
Error in ==> BSplineEval at 4
yy(t(j) <= xx & xx < t(j+1)) = 1;
d = [-1,-0.5,0,0.6,1.4,0.7,-0.1,-0.8;...
0,0.3,0.5,0.4,0.1,-0.4,-0.5,-0.3];
plot(d(1,:),d(2,:),'*')
vertices=[1,2,3,4;5,6,7,8]
vertices =
1 2 3 4
5 6 7 8
repmat(vertices,2,1)
ans =
1 2 3 4
5 6 7 8
1 2 3 4
5 6 7 8
reshape(repmat(vertices,2,1),2,8)
ans =
1 1 2 2 3 3 4 4
5 5 6 6 7 7 8 8
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves2d
xx=linspace(-5,5);
plot(xx,N(1,xx-1))
plot(xx,N(1,xx-2))
plot(xx,N(1,xx-3))
plot(xx,N(1,xx-4))
xx=linspace(-10,10);
plot(xx,N(1,xx-5))
plot(xx,N(1,xx-6))
plot(xx,N(1,xx+3))
plot(xx,N(2,xx-1))
xx=linspace(-10,10,1000);
plot(xx,N(2,xx-1))
plot(xx,N(2,xx-2))
plot(xx,N(2,xx-3))
plot(xx,N(3,xx-1))
plot(xx,N(3,xx-3))
plot(xx,N(4,xx-1))
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves3d
d
d =
Columns 1 through 5
0 0.3681 0.6845 0.9048 0.9980
0 0.4818 0.8443 0.9980 0.9048
0 0.5878 0.9511 0.9511 0.5878
Columns 6 through 10
0.9511 0.7705 0.4818 0.1253 -0.2487
0.5878 0.1253 -0.3681 -0.7705 -0.9823
0.0000 -0.5878 -0.9511 -0.9511 -0.5878
Columns 11 through 15
-0.5878 -0.8443 -0.9823 -0.9823 -0.8443
-0.9511 -0.6845 -0.2487 0.2487 0.6845
-0.0000 0.5878 0.9511 0.9511 0.5878
Columns 16 through 20
-0.5878 -0.2487 0.1253 0.4818 0.7705
0.9511 0.9823 0.7705 0.3681 -0.1253
0.0000 -0.5878 -0.9511 -0.9511 -0.5878
Columns 21 through 25
0.9511 0.9980 0.9048 0.6845 0.3681
-0.5878 -0.9048 -0.9980 -0.8443 -0.4818
-0.0000 0.5878 0.9511 0.9511 0.5878
Columns 26 through 30
0.0000 -0.3681 -0.6845 -0.9048 -0.9980
-0.0000 0.4818 0.8443 0.9980 0.9048
0.0000 -0.5878 -0.9511 -0.9511 -0.5878
Columns 31 through 35
-0.9511 -0.7705 -0.4818 -0.1253 0.2487
0.5878 0.1253 -0.3681 -0.7705 -0.9823
-0.0000 0.5878 0.9511 0.9511 0.5878
Columns 36 through 40
0.5878 0.8443 0.9823 0.9823 0.8443
-0.9511 -0.6845 -0.2487 0.2487 0.6845
0.0000 -0.5878 -0.9511 -0.9511 -0.5878
Columns 41 through 45
0.5878 0.2487 -0.1253 -0.4818 -0.7705
0.9511 0.9823 0.7705 0.3681 -0.1253
-0.0000 0.5878 0.9511 0.9511 0.5878
Columns 46 through 50
-0.9511 -0.9980 -0.9048 -0.6845 -0.3681
-0.5878 -0.9048 -0.9980 -0.8443 -0.4818
0.0000 -0.5878 -0.9511 -0.9511 -0.5878
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
curves3d
x=linspace(0,2*pi,10);
y=sin(x);
bspline3(x,y)
ans =
form: 'B-'
knots: [1x14 double]
coefs: [1x10 double]
number: 10
order: 4
dim: 1
B=bspline3(x,y);
B.knots
ans =
Columns 1 through 5
0 0 0 0 1.3963
Columns 6 through 10
2.0944 2.7925 3.4907 4.1888 4.8869
Columns 11 through 14
6.2832 6.2832 6.2832 6.2832
x
x =
Columns 1 through 5
0 0.6981 1.3963 2.0944 2.7925
Columns 6 through 10
3.4907 4.1888 4.8869 5.5851 6.2832
B.coefs
ans =
Columns 1 through 5
0 0.4830 1.1127 0.9390 0.3711
Columns 6 through 10
-0.3711 -0.9390 -1.1127 -0.4830 -0.0000
xx=linspace(0,2*pi,100);
plot(xx,bspline3(x,y,xx))
plot(xx,bspline3(x,y,xx),x,y,'*')
norm(bspline3(x,y,xx)-spline(x,y,xx),inf)
ans =
3.3307e-16
help csapi
CSAPI Cubic spline interpolant with not-a-knot end condition.
PP = CSAPI(X,Y) returns the cubic spline interpolant (in ppform) to the
given data (X,Y) using the not-a-knot end conditions.
The interpolant matches, at the data site X(j), the given data value
Y(:,j), j=1:length(X). The data values may be scalars, vectors, matrices,
or even ND-arrays. Data points with the same site are averaged.
For interpolation to gridded data, see below.
CSAPI(X,Y,XX) is the same as FNVAL(CSAPI(X,Y),XX).
For example,
values = csapi([-1:5]*(pi/2),[-1 0 1 0 -1 0 1], linspace(0,2*pi));
gives a surprisingly good fine sequence of values for the sine over its
period.
It is also possible to interpolate to data values on a rectangular grid,
as follows:
PP = CSAPI({X1, ...,Xm},Y) returns the m-cubic spline interpolant (in
ppform) that matches the data value Y(:,j1,...,jm) at the data site
(X1(j1), ..., Xm(jm)), for ji=1:length(Xi) and i=1:m.
The entries of each Xi must be distinct. Y must have size
[d,length(X1),...,.length(Xm)], with d a vector of natural numbers, and
with an empty d acceptable when the function is to be scalar-valued.
CSAPI({X1, ...,Xm},Y,XX) is the same as FNVAL(CSAPI({X1,...,Xm},Y),XX).
For example, the statements
x = -1:.2:1; y=-1:.25:1; [xx, yy] = ndgrid(x,y);
z = sin(10*(xx.^2+yy.^2)); pp = csapi({x,y},z);
fnplt(pp)
produce the picture of an interpolant to a bivariate function.
Use of MESHGRID instead of NDGRID here would produce an error.
See also csape, spapi, spline, ndgrid.
Reference page in Help browser
doc csapi
help spapi
SPAPI Spline interpolation.
SPAPI(KNOTS,X,Y) (with both KNOTS and X vectors)
returns the spline f (if any) of order
k := length(KNOTS) - length(X)
with knot sequence KNOTS for which Y(:,j) equals f(X(j)) , all j.
This is taken in the osculatory sense in case some data sites are
repeated, i.e., in the sense that D^m(j) f(X(j)) = Y(:,j) with
m(j) := #{ ispaps, spap2.
Reference page in Help browser
doc spapi
diary off