clc
clear

x = [0 3 6 9 12 15 18 21 24 27 30];
y = [5.13 3.20 2.46 1.74 1.18 1.03 0.574 0.424 0.293 0.197 0.155];

p = polyfit(x, log(y), 1);
b = p(1);
a = exp(p(2));

xfit = linspace(0,30,500);
yfit = a * exp(b*xfit);
x_est = 16.7;
y_est = a * exp(b*x_est);

plot(x, y, 'ro', 'MarkerSize', 8, 'LineWidth', 1.5);
hold on;
plot(xfit, yfit, 'b-', 'LineWidth', 2);
plot(x_est, y_est, 'ko', 'MarkerSize', 10, 'LineWidth', 2);

xlabel('x');
ylabel('y');
title('Final Exam Problem No. 6, by "Kimberly Randle"');
legend('Original Data', 'Exponential Fit', 'Estimated Point');

grid on;
disp(['Estimated y at x = 16.7 is: ', num2str(y_est)]);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: