函数名 功能
Language 求已知数据点的拉格朗日插值多项式
Atken 求已知数据点的艾特肯插值多项式
Newton 求已知数据点的均差形式的牛顿插值多项式
Newtonforward 求已知数据点的前向牛顿差分插值多项式
Newtonback 求已知数据点的后向牛顿差分插值多项式
Gauss 求已知数据点的高斯插值多项式
Hermite 求已知数据点的埃尔米特插值多项式
SubHermite 求已知数据点的分段三次埃尔米特插值多项式及其插值点处的值
SecSample 求已知数据点的二次样条插值多项式及其插值点处的值
ThrSample1 求已知数据点的第一类三次样条插值多项式及其插值点处的值
ThrSample2 求已知数据点的第二类三次样条插值多项式及其插值点处的值
ThrSample3 求已知数据点的第三类三次样条插值多项式及其插值点处的值
BSample 求已知数据点的第一类B样条的插值
DCS 用倒差商算法求已知数据点的有理分式形式的插值分式
Neville 用Neville算法求已知数据点的有理分式形式的插值分式
FCZ 用倒差商算法求已知数据点的有理分式形式的插值分式
DL 用双线性插值求已知点的插值
DTL 用二元三点拉格朗日插值求已知点的插值
DH 用分片双三次埃尔米特插值求插值点的z坐标

function f = Atken(x,y,x0)
syms t;
if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end %检错

y1(1:n) = t; %符号函数数组要赋初值
for(i=1:n-1)
for(j=i+1:n)
y1(j) = y(j)*(t-x(i))/(x(j)-x(i))+y(i)*(t-x(j))/(x(i)-x(j));
end
y = y1;
simplify(y1);
end

if(nargin == 3)
f = subs(y1(n),'t',x0); %计算插值点的函数值
else
simplify(y1(n)); %化简
f = collect(y1(n)); %将插值多项式展开
f = vpa(f,6); %将插值多项式的系数化成6位精度的小数
end

function f0 = BSample(a,b,n,y,y_1,y_N,x0)
f0 = 0.0;
h = (b-a)/n;
c = zeros(n+3,1);
b = zeros(n+1,1);

for i=0:n-1
if(a+i*h<=x0) && (a+i*h+h>=x0)
index = i;
break;
end
end %找到x0所在区间

A = diag(4*ones(n+1,1));
I = eye(n+1,n+1);
AL = [I(2:n+1,:);zeros(1,n+1)];
AU = [zeros(1,n+1);I(1:n,:)];
A = A+AL+AU; %形成系数矩阵
for i=2:n
b(i,1) = 6*y(i);
end
b(1) = 6*y(1)+2*h*y_1;
b(n+1) = 6*y(n+1)-2*h*y_N;
d = followup(A,b); %用追赶法求出系数
c(2:n+2) = d;
c(1) = c(2) - 2*h*y_1; %c(-1)
c(n+3) = c(3)+2*h*y_N; %c(n+1)

x1 = (a+index*h-h-x0)/h;
m1 = c(index+1)*(-((abs(x1))^3)/6+(x1)^2-2*abs(x1)+4/3);
x2 = (a+index*h-x0)/h;
m2 = c(index+2)*((abs(x2))^3/2-(x2)^2+2/3);
x3 = (a+index*h+h-x0)/h;
m3 = c(index+3)*((abs(x3))^3/2-(x3)^2+2/3);
x4 = (a+index*h+2*h-x0)/h;
m4 = c(index+4)*(-((abs(x4))^3)/6+(x4)^2-2*abs(x4)+4/3);
f0 = m1+m2+m3+m4; %求出插值

function f = DCS(x,y,x0)
syms t;

if(length(x) == length(y))
n = length(x);
c(1:n) = 0.0;
else
disp('x和y的维数不相等!');
return;
end

c(1) = y(1);
for(i=1:n-1)
for(j=i+1:n)
y1(j) = (x(j)-x(i))/(y(j)-y(i));
end
c(i+1) = y1(i+1);
y = y1;
end

f = c(n);
for(i=1:n-1)
f = c(n-i) + (t-x(n-i))/f;
f = vpa(f,6);
if(i==n-1)
if(nargin == 3)
f = subs(f,'t',x0);
else
f = vpa(f,6);
end
end
end;

function fz = DH(x,y,x0,y0,zx,zy,zxy)
n = length(x);
m = length(y);

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index_x = i;
break;
end
end %找到x0所在区间
for i=1:m
if(y(i)<=y0)&& (y(i+1)>=y0)
index_y = i;
break;
end
end %找到y0所在区间
hx = x(index_x+1) - x(index_x);
hy = y(index_y+1) - y(index_y);
tx = (x0 - x(index_x))/hx; %插值坐标归一化
ty = (y0 - y(index_y))/hy; %插值坐标归一化

Hl = [(1-tx)^2*(1+2*tx) tx*tx*(3-2*tx) tx*(1-tx)^2 tx*tx*(tx-1)]; %左向量
Hr = [(1-ty)^2*(1+2*ty); ty*ty*(3-2*ty); ty*(1-ty)^2 ; ty*ty*(ty-1)]; %右向量
C = [Z(index_x, index_y) Z(index_x,index_y+1) zy(index_x, index_y) ...
zy(index_x, index_y+1);
Z(index_x+1, index_y) Z(index_x+1,index_y+1) zy(index_x+1, index_y) ...
zy(index_x+1, index_y+1);
zx(index_x, index_y) zy(index_x, index_y+1) zxy(index_x, index_y) ...
zxy(index_x, index_y+1);
zx(index_x+1, index_y) zy(index_x+1, index_y+1) zxy(index_x+1, index_y) ...
zxy(index_x+1, index_y+1)]; %C矩阵
fz = Hl*C*Hr;

function fz = DL(x,y,Z,x0,y0,eps)
n = length(x);
m = length(y);

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index_x = i;
break;
end
end %找到x0所在区间
for i=1:m
if(y(i)<=y0)&& (y(i+1)>=y0)
index_y = i;
break;
end
end %找到y0所在区间

A = [1 x(index_x) y(index_y) x(index_x)* y(index_y);
1 x(index_x+1) y(index_y+1) x(index_x+1)* y(index_y+1);
1 x(index_x) y(index_y+1) x(index_x)* y(index_y+1);
1 x(index_x+1) y(index_y) x(index_x+1)* y(index_y)];
iA = inv(A);
B = iA*[Z(index_x,index_y); Z(index_x+1,index_y+1); Z(index_x,index_y+1);
Z(index_x+1,index_y)];
fz = [1 x0 y0 x0*y0]*B;

function fz = DTL(x,y,Z,x0,y0)
syms s t;
f = 0.0;
n = length(x);
m = length(y);

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index_x = i;
break;
end
end %找到x0所在区间
for i=1:m
if(y(i)<=y0)&& (y(i+1)>=y0)
index_y = i;
break;
end
end %找到y0所在区间

if index_x == 1
cx(1:3) = index_x:(index_x+2);
else
if index_x == n-1
cx(1:3) = (index_x-1):(index_x+1);
else
if abs(x(index_x-1)-x0)>abs(x(index_x+2)-x0)
cx(1:3) = (index_x):(index_x+2);
else
cx(1:3) = (index_x-1):(index_x+1);
end
end
end %找到离x0最近的三个x坐标

if index_y == 1
cy(1:3) = index_y:(index_y+2);
else
if index_y == m-1
cy(1:3) = (index_y-1):(index_y+1);
else
if abs(y(index_y-1)-y0)>=abs(y(index_y+2)-y0)
cy(1:3) = (index_y):(index_y+2);
else
cy(1:3) = (index_y-1):(index_y+1);
end
end
end %找到离y0最近的三个y坐标

for i=1:3
i1 = mod(i+1,3);
if(i1 == 0)
i1 = 3;
end
i2 = mod(i+2,3);
if(i2 == 0)
i2 = 3;
end
for j=1:3
j1 = mod(j+1,3);
if(j1 == 0)
j1 = 3;
end
j2 = mod(j+2,3);
if(j2 == 0)
j2 = 3;
end
f = f+Z(cx(i),cy(j))*((t-x(cx(i1)))*(t-x(cx(i2)))/(x(cx(i))-x(cx(i1)))/(x(cx(i))-x(cx(i2))))* ...
(s-y(cy(j1)))*(s-y(cy(j2)))/(y(cy(j))-y(cy(j1)))/(y(cy(j))-y(cy(j2)));
%插值多项式
end
end
fz = subs(f,'[t s]',[x0 y0]);

function [f,x0] = FCZ(x,y,y0)
syms t;
if(length(x) == length(y))
n = length(x);
c(1:n) = 0.0;
else
disp('x和y的维数不相等!');
return;
end

c(1) = x(1);
y1 = x;
for(i=1:n-1)
for(j=i+1:n)
y2(j) = (y1(j)-y1(i))/(y(j)-y(i));
end
c(i+1) = y2(i+1);
y1 = y2;
end

f = c(1);
for(i=1:n-1)
ff = c(i+1);
for(j=1:i)
ff = ff*(t-y(j));
end
f = f + ff;
end;
x0 = subs(f,'t',y0);

function f = Gauss(x,y,x0)

if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end

xx =linspace(x(1),x(n),(x(2)-x(1)));
if(xx ~= x)
disp('节点之间不是等距的!');
return;
end

if( mod(n,2) ==1)
if(nargin == 2)
f = GStirling(x,y,n);
else if(nargin == 3)
f = GStirling(x,y,n,x0);
end
end
else
if(nargin == 2)
f = GBessel(x,y,n);
else if(nargin == 3)
f = GBessel(x,y,n,x0);
end
end
end

function f = GStirling(x,y,n,x0)
syms t;
nn = (n+1)/2;
f = y(nn);

for(i=1:n-1)
for(j=i+1:n)
y1(j) = y(j)-y(j-1);
end
if(mod(i,2)==1)
c(i) = (y1((i+n)/2)+y1((i+n+2)/2))/2;
else
c(i) = y1((i+n+1)/2)/2;
end

if(mod(i,2)==1)
l = t+(i-1)/2;
for(k=1:i-1)
l = l*(t+(i-1)/2-k);
end
else
l_1 = t+i/2-1;
l_2 = t+i/2;
for(k=1:i-1)
l_1 = l_1*(t+i/2-1-k);
l_2 = l_2*(t+i/2-k);
end
l = l_1 + l_2;
end

l = l/factorial(i);
f = f + c(i)*l;
simplify(f);
f = vpa(f, 6);
y = y1;

if(i==n-1)
if(nargin == 4)
f = subs(f,'t',(x0-x(nn))/(x(2)-x(1)));
end
end
end

function f = GBessel(x,y,n,x0)
syms t;
nn = n/2;
f = (y(nn)+y(nn+1))/2;

for(i=1:n-1)
for(j=i+1:n)
y1(j) = y(j)-y(j-1);
end
if(mod(i,2)==1)
c(i) = y1((i+n+1)/2)/2;
else
c(i) = (y1((i+n)/2)+y1((i+n+2)/2))/2;
end

if(mod(i,2)==0)
l = t+i/2-1;
for(k=1:i-1)
l = l*(t+i/2-1-k);
end
else
l_1 = t+(i-1)/2;
l_2 = t+(i-1)/2-1;
for(k=1:i-1)
l_1 = l_1*(t+(i-1)/2-k);
l_2 = l_2*(t+(i-1)/2-1-k);
end
l = l_1 + l_2;
end

l = l/factorial(i);
f = f + c(i)*l;
simplify(f);
f = vpa(f, 6);
y = y1;

if(i==n-1)
if(nargin == 4)
f = subs(f,'t',(x0-x(nn))/(x(2)-x(1)));
end
end
end

function f = Hermite(x,y,y_1,x0)
syms t;
f = 0.0;

if(length(x) == length(y))
if(length(y) == length(y_1))
n = length(x);
else
disp('y和y的导数的维数不相等!');
return;
end
else
disp('x和y的维数不相等!');
return;
end

for i=1:n
h = 1.0;
a = 0.0;
for j=1:n
if( j ~= i)
h = h*(t-x(j))^2/((x(i)-x(j))^2);
a = a + 1/(x(i)-x(j));
end
end

f = f + h*((x(i)-t)*(2*a*y(i)-y_1(i))+y(i));

if(i==n)
if(nargin == 4)
f = subs(f,'t',x0);
else
f = vpa(f,6);
end
end
end

function f = Language(x,y,x0)
syms t;
if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end %检错

f = 0.0;
for(i = 1:n)
l = y(i);
for(j = 1:i-1)
l = l*(t-x(j))/(x(i)-x(j));
end;
for(j = i+1:n)
l = l*(t-x(j))/(x(i)-x(j)); %计算拉格朗日基函数
end;

f = f + l; %计算拉格朗日插值函数
simplify(f); %化简

if(i==n)
if(nargin == 3)
f = subs(f,'t',x0); %计算插值点的函数值
else
f = collect(f); %将插值多项式展开
f = vpa(f,6); %将插值多项式的系数化成6位精度的小数
end
end
end

function f = Neville(x,y,x0)
syms t;

if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end

y1(1:n) = t;
for(i=1:n-1)
for(j=i+1:n)
if(j==2)
y1(j) = y(j)+(y(j)-y(j-1))/((t-x(j-i))/(t-x(j)))*(1-(y(j)-y(j-1))/y(j));
else
y1(j) = y(j)+(y(j)-y(j-1))/((t-x(j-i))/(t-x(j)))*(1-(y(j)-y(j-1))/(y(j)-y(j-2)));
end
end
y = y1;
if(i==n-1)
if(nargin == 3)
f = subs(y(n-1),'t',x0);
else
f = vpa(y(n-1),6);
end
end

end

function f = Newton(x,y,x0)
syms t;

if(length(x) == length(y))
n = length(x);
c(1:n) = 0.0;
else
disp('x和y的维数不相等!');
return;
end

f = y(1);
y1 = 0;
l = 1;

for(i=1:n-1)
for(j=i+1:n)
y1(j) = (y(j)-y(i))/(x(j)-x(i));
end
c(i) = y1(i+1);
l = l*(t-x(i));
f = f + c(i)*l;
simplify(f);
y = y1;

if(i==n-1)
if(nargin == 3)
f = subs(f,'t',x0);
else
f = collect(f); %将插值多项式展开
f = vpa(f, 6);
end
end
end

function f = Newtonback(x,y,x0)
syms t;

if(length(x) == length(y))
n = length(x);
c(1:n) = 0.0;
else
disp('x和y的维数不相等!');
return;
end

f = y(n);
y1 = 0;

xx =linspace(x(1),x(n),(x(2)-x(1)));
if(xx ~= x)
disp('节点之间不是等距的!');
return;
end

for(i=1:n-1)
for(j=i+1:n)
y1(j) = y(j)-y(j-1);
end
c(i) = y1(n);
l = t;
for(k=1:i-1)
l = l*(t+k);
end;

f = f + c(i)*l/factorial(i);
simplify(f);
y = y1;

if(i==n-1)
if(nargin == 3)
f = subs(f,'t',(x0-x(n))/(x(2)-x(1)));
else
f = collect(f);
f = vpa(f, 6);
end
end
end

function f = Newtonforward(x,y,x0)
syms t;

if(length(x) == length(y))
n = length(x);
c(1:n) = 0.0;
else
disp('x和y的维数不相等!');
return;
end

f = y(1);
y1 = 0;

xx =linspace(x(1),x(n),(x(2)-x(1)));
if(xx ~= x)
disp('节点之间不是等距的!');
return;
end

for(i=1:n-1)
for(j=1:n-i)
y1(j) = y(j+1)-y(j);
end
c(i) = y1(1);
l = t;
for(k=1:i-1)
l = l*(t-k);
end;

f = f + c(i)*l/factorial(i);
simplify(f);
y = y1;

if(i==n-1)
if(nargin == 3)
f = subs(f,'t',(x0-x(1))/(x(2)-x(1)));
else
f = collect(f);
f = vpa(f, 6);
end
end
end

function [f,f0,fd0] = SecSample (x,y,y_1,x0)
syms t;
f = 0.0;
f0 = 0.0;

if(length(x) == length(y))
if(length(y) == length(y_1))
n = length(x);
else
disp('y和y的导数的维数不相等!');
return;
end
else
disp('x和y的维数不相等!');
return;
end %维数检查

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

d = y_1(1)*(x(2)-x(1))/2+y(1);
for i=2:n-1
d = d + y_1(i)*(x(i+1)-x(i-1))/2;
end

h = x(index+1) - x(index); %x0所在区间长度
f = y_1(index+1)*(t-x(index))^2/2/h + ...
y_1(index)*(t-x(index+1))^2/2/h + d; %x0所在区间的插值函数
fd = (t-x(index))*y_1(index+1)/h + y_1(index)*(x(index+1)-t)/h;
%x0所在区间的插值函数的导数
f0 = subs(f,'t',x0); %x0处的插值
fd0 = subs(fd,'t',x0); % x0处的导数插值

function [f,f0] = SubHermite(x,y,y_1,x0)
syms t;
f = 0.0;
f0 = 0.0;

if(length(x) == length(y))
if(length(y) == length(y_1))
n = length(x);
else
disp('y和y的导数的维数不相等!');
return;
end
else
disp('x和y的维数不相等!');
return;
end %维数检查

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

h = x(index+1) - x(index); %x0所在区间长度
fl = y(index)*(1+2*(t-x(index))/h)*(t-x(index+1))^2/h/h + ...
y(index+1)*(1-2*(t-x(index+1))/h)*(t-x(index))^2/h/h;
fr = y_1(index)*(t-x(index))*(t-x(index+1))^2/h/h + ...
y_1(index+1)*(t-x(index+1))*(t-x(index))^2/h/h;
f = fl + fr; %x0所在区间的插值函数
f0 = subs(f,'t',x0); %x0处的插值

function [f,f0] = ThrSample1 (x,y,y_1, y_N,x0)
syms t;
f = 0.0;
f0 = 0.0;

if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end %维数检查

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

A = diag(2*ones(1,n)); %求解m的系数矩阵
u = zeros(n-2,1);
lamda = zeros(n-1,1);
c = zeros(n,1);
for i=2:n-1
u(i-1) = (x(i)-x(i-1))/(x(i+1)-x(i-1));
lamda(i) = (x(i+1)-x(i))/(x(i+1)-x(i-1));
c(i) = 3*lamda(i)*(y(i)-y(i-1))/(x(i)-x(i-1))+ ...
3*u(i-1)*(y(i+1)-y(i))/(x(i+1)-x(i));
A(i, i+1) = u(i-1);
A(i, i-1) = lamda(i); %形成系数矩阵及向量c
end
c(1) = 2*y_1;
c(n) = 2*y_N;

m = followup(A,c); %用追赶法求解方程组
h = x(index+1) - x(index); %x0所在区间长度
f = y(index)*(2*(t-x(index))+h)*(t-x(index+1))^2/h/h/h + ...
y(index+1)*(2*(x(index+1)-t)+h)*(t-x(index))^2/h/h/h + ...
m(index)*(t-x(index))*(x(index+1)-t)^2/h/h - ...
m(index+1)*(x(index+1)-t)*(t-x(index))^2/h/h;
%x0所在区间的插值函数
f0 = subs(f,'t',x0); %x0处的插值

function [f,f0] = ThrSample2 (x,y,y2_1, y2_N,x0)
syms t;
f = 0.0;
f0 = 0.0;

if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end %维数检查

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

A = diag(2*ones(1,n)); %求解m的系数矩阵
A(1,2) = 1;
A(n,n-1) = 1;
u = zeros(n-2,1);
lamda = zeros(n-1,1);
c = zeros(n,1);
for i=2:n-1
u(i-1) = (x(i)-x(i-1))/(x(i+1)-x(i-1));
lamda(i) = (x(i+1)-x(i))/(x(i+1)-x(i-1));
c(i) = 3*lamda(i)*(y(i)-y(i-1))/(x(i)-x(i-1))+ ...
3*u(i-1)*(y(i+1)-y(i))/(x(i+1)-x(i));
A(i, i+1) = u(i-1);
A(i, i-1) = lamda(i); %形成系数矩阵及向量c
end
c(1) = 3*(y(2)-y(1))/(x(2)-x(1))-(x(2)-x(1))*y2_1/2;
c(n) = 3*(y(n)-y(n-1))/(x(n)-x(n-1))-(x(n)-x(n-1))*y2_N/2;

m = followup(A,c); %用追赶法求解方程组
h = x(index+1) - x(index); %x0所在区间长度
f = y(index)*(2*(t-x(index))+h)*(t-x(index+1))^2/h/h/h + ...
y(index+1)*(2*(x(index+1)-t)+h)*(t-x(index))^2/h/h/h + ...
m(index)*(t-x(index))*(x(index+1)-t)^2/h/h - ...
m(index+1)*(x(index+1)-t)*(t-x(index))^2/h/h;
%x0所在区间的插值函数
f0 = subs(f,'t',x0); %x0处的插值

function [f,f0] = ThrSample3 (x,y,x0)
syms t;
f = 0.0;
f0 = 0.0;

if(length(x) == length(y))
n = length(x);
else
disp('x和y的维数不相等!');
return;
end %维数检查

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

for i=1:n
if(x(i)<=x0)&& (x(i+1)>=x0)
index = i;
break;
end
end %找到x0所在区间

A = diag(2*ones(1,n-1)); %求解m的系数矩阵
h0 = x(2)-x(1);
h1 = x(3)–x(2);
he = x(n)-x(n-1);
A(1,2) = h0/(h0+h1);
A(1,n-1) = 1 - A(1,2);
A(n-1,1) = he/(h0+he);
A(n-1,n-2) = 1 - A(n-1,1);

c = zeros(n-1,1);
c(1) = 3* A(1,n-1)*(y(2)-y(1))/h0 + 3* A(1,2)*(y(3)-y(2))/h1;
for i=2:n-2
u = (x(i)-x(i-1))/(x(i+1)-x(i-1));
lamda = (x(i+1)-x(i))/(x(i+1)-x(i-1));
c(i) = 3*lamda*(y(i)-y(i-1))/(x(i)-x(i-1))+ ...
3*u*(y(i+1)-y(i))/(x(i+1)-x(i));
A(i, i+1) = u;
A(i, i-1) = lamda; %形成系数矩阵及向量c
end
c(n-1) = 3*( he*(y(2)-y(1))/h0+h0*( y(n)-y(n-1))/he)/(h0+he);

m = zeros(n,1);
[m(2:n),Q,R] = qrxq(A,c); %用qr分解法法求解方程组
m(1) = m(n);
h = x(index+1) - x(index); %x0所在区间长度
f = y(index)*(2*(t-x(index))+h)*(t-x(index+1))^2/h/h/h + ...
y(index+1)*(2*(x(index+1)-t)+h)*(t-x(index))^2/h/h/h + ...
m(index)*(t-x(index))*(x(index+1)-t)^2/h/h - ...
m(index+1)*(x(index+1)-t)*(t-x(index))^2/h/h;
%x0所在区间的插值函数
f0 = subs(f,'t',x0); %x0处的插值

插值代码17个---MATLAB的更多相关文章

  1. 机器学习-一对多(多分类)代码实现(matlab)

    %% Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all % Instructions % ------------ % % ...

  2. 机器学习-反向传播算法(BP)代码实现(matlab)

    %% Machine Learning Online Class - Exercise 4 Neural Network Learning % Instructions % ------------ ...

  3. 线性回归代码实现(matlab)

    1 代价函数实现(cost function) function J = computeCost(X, y, theta) %COMPUTECOST Compute cost for linear r ...

  4. 如何加速MATLAB代码运行

    学习笔记 V1.0 2015/4/17 如何加速MATLAB代码运行 概述 本文源于LDPCC的MATLAB代码,即<CCSDS标准的LDPC编译码仿真>.由于代码的问题,在信息位长度很长 ...

  5. 多项式函数插值:全域多项式插值(一)单项式基插值、拉格朗日插值、牛顿插值 [MATLAB]

    全域多项式插值指的是在整个插值区域内形成一个多项式函数作为插值函数.关于多项式插值的基本知识,见“计算基本理论”. 在单项式基插值和牛顿插值形成的表达式中,求该表达式在某一点处的值使用的Horner嵌 ...

  6. MATLAB Coder从MATLAB生成C/C++代码步骤

    MATLAB Coder可以从MATLAB代码生成独立的.可读性强.可移植的C/C++代码. 使用MATLAB Coder产生代码的3个步骤: 准备用于产生代码的MATLAB算法: 检查MATLAB代 ...

  7. Matlab程序 转C++/Opencv基于Mat 不可不知的17个函数

    1.matlab中的imread相当于OpenCV中的cvLoadImage(imageName,  CV_LOAD_IAMGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR): ...

  8. 调试和运行matlab代码(源程序)的技巧和教程

    转载请标明出处:专注matlab代码下载的网站http://www.downma.com/ 本文主要给大家分享使用matlab编写代码,完成课程设计.毕业设计或者研究项目时,matlab调试程序的技巧 ...

  9. 高斯混合模型(GMM)及MATLAB代码

    之前在学习中遇到高斯混合模型,卡了很长一段时间,在这里记下学习中的一些问题以及解决的方法.希望看到这篇文章的同学们对高斯混合模型能有一些基本的概念.全文不废话,直接上重点. 本文将从以下三个问题详解高 ...

随机推荐

  1. java中对象的创建过程

    public class Test1 { public static void main(String[] args) { new B(); System.out.println("---- ...

  2. 论文阅读笔记四十三:DeeperLab: Single-Shot Image Parser(CVPR2019)

    论文原址:https://arxiv.org/abs/1902.05093 github:https://github.com/lingtengqiu/Deeperlab-pytorch 摘要 本文提 ...

  3. ajax与后台交互案例

    BBS项目 //BBS项目,注册页面ajax请求 // 1.实现照片预览 $("#up_myhead").change(function () { // 获取input选择的文件 ...

  4. Class--2019-04-14

    获取class对象,有三种方法: 1.通过类名.class直接访问 Class c = Integer.class; 2.通过Class.forName(类名)函数获取 Class c = Class ...

  5. Facebook授权登录

    1.注册开发者账号 登陆facebook开发者平台 (https://developers.facebook.com/), 注册facebook开发者账号. 2.Facebook登录Key Hash配 ...

  6. 几个简单排序算法的Python实现

    一,冒泡排序 冒泡排序我就不多讲了,大体上就是比较相邻的两个数,每次把较大的数沉底.流程图大致上如下: 图是截得别人的,只是说明一下,代码没有参看别人的,写的不好,有更好的写法可以一起探讨.下面是代码 ...

  7. BSUIR Open Finals

    A. Game with chocolates 因为差值必须是$P$的幂,故首先可以$O(\log n)$枚举出先手第一步所有取法,判断之后的游戏是否先手必败. 对于判断,首先特判非法的情况,并假设$ ...

  8. node.js 模块的分类

    模块的简单分类可分为三类: 第一类分别为:核心模块:http.fs.path.... 第二类分别为:文件模块:var (util)=require('.util.js') 第三方类分别为:其他模块:v ...

  9. Codechef August Challenge 2018 : Interactive Matrix

    传送门 首先整个矩阵可以被分为很多小矩阵,小矩阵内所有行的单调性是一样的,所有列的单调性是一样的. 考虑如何在这样一个小矩阵中找出答案.我的策略是每次取四个角中最大值和最小值的点,这样可以每次删掉一行 ...

  10. react_app 项目开发 (8)_角色管理_用户管理----权限管理 ---- shouldComponentUpdate

    角色管理 性能优化(前端面试) 需求:只要执行 setState(), 就会调用 render  重新渲染.由于有时调用了 setState,但是并没有发生状态的改变,以致于不必要的刷新 解决: 重写 ...