x = [0,1,2,3,4,5,6,7] y = [0.07, 0.05, 0.03, 0.02, 0.01, 0.005, 0.002, 0.0007]
I want to find what x is when y= 0.000001 and I tried below but it gives me a wrong value.
10^(interp1(log10(y),x,10^-6, 'linear','extrap'))
Also, would linear extrapolation be possible if I only had two points like so,
x = [6,7] y = [0.002, 0.0007]
interp1'slinear-extrapfunction simply extends the last (or first) segment in the piecewise linear fit made from the points. It doesn't actually create a least-squares fit. This is very evident in the image below:How did I get this image? I fixed the following problems with your code: You are interpolating
log10(y)vsx.interp1needs to belog10(new_y). Fornew_y = 10^-6, you actually need to pass-6.interp1()will give younew_x. You're raising10to the result ofinterp1, which is wrong.The short answer to your second question is yes!.
Longer answer: replace
xandyin my code above and see if it works(spoiler: it does).Note: I ran this code in Octave Online because I don't have a local MATLAB installation. Shouldn't make a difference to the answer though.