MATLAB: Need to find the Y value at X = 0!! Extrapolation!!

curve fittingextrapolationx = 0

Hi guys!
I have the following data for my experiment involving weight loss vs time, I need to find out the weight at time (x) = 0
Time (s) x = [227 600 1200 2280 3460 4380 6300 9180 12720 14880 16440 17100 63000 95400]
Weight (g) y = [0.8845 0.8581 0.8399 0.8267 0.8170 0.8105 0.7969 0.7850 0.7760 0.772 0.7709 0.7688 0.7407 0.737]
Can anyone help? I hope its possible!
Thanks! Dan

Best Answer

To extrapolate with interp1, you need to specify a method and tell the function specifically that you want it to extrapolate. Otherwise, it produces NaN for the extrapolated value:
% Time (s)
x = [227 600 1200 2280 3460 4380 6300 9180 12720 14880 16440 17100 63000 95400];
% Weight (g)
y = [0.8845 0.8581 0.8399 0.8267 0.8170 0.8105 0.7969 0.7850 0.7760 0.772 0.7709 0.7688 0.7407 0.737];
y0 = interp1(x, y, 0, 'linear', 'extrap');
figure(1)
plot(x, y)
hold on
plot(0, y0, '*r')
hold off
grid