MATLAB: Exponential decay extrap to y=0

expexponential

Hi peeps,
I am trying to fit an exponential decay curve to my data;
x = [0;10;20;30;40;50;60]; %time in minutes
y = [12.5; 7.8;5.1;3.2;2;1.2;0.7];
I am reasonably new to matlab and I am unsure about how to fit an exponential curve to the plot that reaches y=0
Any assistance would be greatly appreciated.
Many thanks,
Jamie

Best Answer

Hello,
You could try this
clear
close all
x0 = linspace(0,100,100);
x = [0;10;20;30;40;50;60]; %time in minutes
y = [12.5; 7.8;5.1;3.2;2;1.2;0.7];
f = fittype('exp(-a*x+b)');
[fit1,gof,fitinfo] = fit(x,y,f,'StartPoint',[1 0]); % ,'StartPoint',1
figure
plot(x0,fit1(x0),'r',x,y,'o')
Related Question