Since you are starting with:
and linearising it yields:
however ‘aPrime’ and ‘bPrime’ are reversed with respect to the way polyfit works.
So polyfit returns:
bPrime = pPrime(1)
aPrime = pPrime(2)
you need to transform only ‘aPrime’. So:
If you want to plot a line-of-fit, you could either use your originally log-transformed equation with log-transformed variables:
log(y) = aPrime + bPrime*t
or:
yfit = exp(log(aPrime)) * exp(b*t)
with your original data.
In code:
t = [11,60,150,200];
y = [800,500,400,90];
yPrime= log(y)
pPrime=polyfit(t,yPrime,1)
aPrime=pPrime(2)
bPrime=pPrime(1)
figure(1)
plot(t, log(y), 'p', t, polyval(pPrime, t), '-r')
figure(2)
plot(t, y, 'p', t, exp(aPrime)*exp(t*bPrime), '-r')
figure(3)
semilogy(t, y, 'p', t, exp(aPrime)*exp(t*bPrime), '-r')
Best Answer