Fit log10 function to data and determine the intercept

10 views (last 30 days)
Hi!
I have data that x is in log10 scale and y is normal. I want to fit a function that should follow the function: y = log10(1/x) + b, where b is the intercept or off set. How do I determine b here?
Sample data here:
x = 0.24. 0.6, 1.2, 2.4, 6, 12, 24
y = 17.2499, 9.8872, 5.6918, 2.7402, 0.6857, 0.1537, 0.0224
The function has be in the form of y = log10(1/x) + b.
Thank you in advance

Answers (1)

Star Strider
Star Strider on 13 Apr 2021
If ‘b’ is the y-intercept, the easiest way is to interpolate:
x = [0.24, 0.6, 1.2, 2.4, 6, 12, 24];
y = [17.2499, 9.8872, 5.6918, 2.7402, 0.6857, 0.1537, 0.0224];
b = interp1(log10(1./x), y, 0);
figure
plot(log10(1./x), y)
hold on
plot(0, b, 'rs')
hold off
grid
legend('Data','b', 'Location','best')
text(0, b, sprintf('b = %.4f \\rightarrow ',b), 'Horiz','right', 'Vert','middle')
.

Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!