%
% This code first reads in data from data4.txt.
% Then it uses cubic spline interpolation to approximate
% the original function
%
clear
figure(3)
clf reset
axes('position',[0.15,0.13,0.75,0.75])
%
load -ascii data4.txt
xd=data4(:,1);
yd=data4(:,2);
%
x=[0:0.05:10];
y=spline(xd,yd,x);
%
plot(xd,yd,'bo','markerfacecolor','b')
hold on
plot(x,y,'k-')
%
set(gca,'fontsize',14)
axis([0,10,-0.9,1.2])
set(gca,'xtick',[0:2:10])
set(gca,'ytick',[-0.5:0.5:1])
xlabel('x')
ylabel('y')
h1=legend('data','cubic spline',4);
set(h1,'fontsize',12)
%
%
