📄 grbf.m
字号:
%The script GRBF givess an example of interpolation
%using a radial-basis function network
% written by S. H. Zak on Feb 12, 1999
d=[.8 .2 .4 .6 .3]';
%d=[.8 .2]';
x=[0 6 7 8 10]';
%x=[0 6]';
phi=[exp(-(x(1)-x(1)).^2/2) exp(-(x(1)-x(2)).^2/2) exp(-(x(1)-x(3)).^2/2) exp(-(x(1)-x(4)).^2/2) exp(-(x(1)-x(5)).^2/2);
exp(-(x(2)-x(1)).^2/2) exp(-(x(2)-x(2)).^2/2) exp(-(x(2)-x(3)).^2/2) exp(-(x(2)-x(4)).^2/2) exp(-(x(2)-x(5)).^2/2)
exp(-(x(3)-x(1)).^2/2) exp(-(x(3)-x(2)).^2/2) exp(-(x(3)-x(3)).^2/2) exp(-(x(3)-x(4)).^2/2) exp(-(x(3)-x(5)).^2/2)
exp(-(x(4)-x(1)).^2/2) exp(-(x(4)-x(2)).^2/2) exp(-(x(4)-x(3)).^2/2) exp(-(x(4)-x(4)).^2/2) exp(-(x(4)-x(5)).^2/2)
exp(-(x(5)-x(1)).^2/2) exp(-(x(5)-x(2)).^2/2) exp(-(x(5)-x(3)).^2/2) exp(-(x(5)-x(4)).^2/2) exp(-(x(5)-x(5)).^2/2)];
w=phi\d;
t=0:0.01:10;
F='w(1)*exp(-(t-x(1)).^2/2)+w(2)*exp(-(t-x(2)).^2/2)+w(3)*exp(-(t-x(3)).^2/2)+w(4)*exp(-(t-x(4)).^2/2)+w(5)*exp(-(t-x(5)).^2/2)';
plot(x,d,'--')
set(gca,'Fontsize',12);grid
hold on
plot(t,eval(F))
xlabel('{\it x}','Fontsize',12)
ylabel('{\it F}({\it x})','Fontsize',12)
title('Linear and radial-basis function based approximations')
hold off
phi1='exp(-(t-x(1)).^2/2)';
phi2='exp(-(t-x(2)).^2/2)';
phi3='exp(-(t-x(3)).^2/2)';
phi4='exp(-(t-x(4)).^2/2)';
phi5='exp(-(t-x(5)).^2/2)';
figure
plot(t,eval(phi1))
hold on
plot(t,eval(phi2))
plot(t,eval(phi3))
plot(t,eval(phi4))
plot(t,eval(phi5))
xlabel('{\it x}','Fontsize',12)
title('Radial-basis functions employed in the approximation','Fontsize',12)
grid
hold off
figure
subplot(2,1,1)
plot(x,d,'--')
hold on
plot(t,eval(F))
%xlabel('{\it x}','Fontsize',12)
ylabel('{\it F}({\it x})','Fontsize',12)
title('(a) Linear and radial-basis function based approximations','Fontsize',12)
%gtext('Linear approximation')
hold off
subplot(2,1,2)
plot(t,eval(phi1))
hold on
plot(t,eval(phi2))
plot(t,eval(phi3))
plot(t,eval(phi4))
plot(t,eval(phi5))
xlabel('{\it x}','Fontsize',12)
title('(b) Radial-basis functions','Fontsize',12)
%title('(b)','Fontsize',12)
hold off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -