%Lecture14c
%Polynomial Interpolation

clc

t=[1:10];

a=4;
b=3;

f=a*2.^(b*t);

figure(1)
plot(t,f,'ro')
axis([0 max(t) 0 max(f)])
xlabel('t')
ylabel('f(t)')
title('Data')

lnf=log(a*2.^(b*t));

figure(2)
plot(t,lnf,'ro')
axis([0 max(t) 0 max(lnf)])
xlabel('t')
ylabel('ln[f(t)]')
title('Data')

tint=[0:0.01:10];

[P,S]=polyfit(t,lnf,1);

aest=exp(P(2))
best=P(1)/log(2)

yint=aest*2.^(best*tint);
figure(1)
hold on
plot(tint,yint,'b-')
axis([0 max(t) 0 max(f)])
xlabel('t')
ylabel('f(t)')
title('Linear Interpolation')

yint=polyval(P,tint);
figure(2)
hold on
plot(tint,yint,'b-')
axis tight
xlabel('t')
ylabel('ln[f(t)]')
title('Linear Interpolation')
hold off


