In: Advanced Math
given the expiremental data below, determine the equation that models the data. first plot the data on both a log-log graph and a semi-log graph. next, use these plots to determine the type of equation that best fits the data. finally determine the equation. x-values= 10,20,50,120,180,200 y values=4600,3200,1130,98,98,12,6
MATLAB Code:
close all
clear
clc
x = [10 20 50 120 180 200];
y = [4600 3200 1130 98 12 6];
figure
subplot(121), loglog(x,y), xlabel('x'), ylabel('y')
title('loglog graph')
subplot(122), semilogy(x,y), xlabel('x'), ylabel('y')
title('semilog graph')
disp('Hence, semilog plot fits the data better.')
disp('The type of equation is: log(y) = a*x + b')
A = [x(:) ones(size(x(:)))];
c = A\log(y(:));
a = c(1); b = c(2);
fprintf('\nThe equation that fits the given data is: log(y) =
(%f)*x + (%f)\n', a, b)
figure
xx = min(x):0.01:max(x);
plot(x,y,'o',xx,exp(a*xx+b)), xlabel('x')
legend('Data Points', 'Curve Fit')
Plots:
Output:
Hence, semilog plot fits the data better.
The type of equation is: log(y) = a*x + b
The equation that fits the given data is: log(y) = (-0.034938)*x
+ (8.776680)