Fit data to an exponential curve using fitdist

4 views (last 30 days)
Hello,
I'm trying to fit the following data to an exponential curve using fitdist. This is the code I have but the graph doesn't fit the data.
VarName6 = [1; 0.5294; 0.2941; 0.2794; 0.1764; 0.1323];
VarName7 = [0; 0.05; 0.15; 0.20; 0.25; 0.30];
x1q = linspace(VarName6(1),VarName6(end),100);
y1q = interp1(VarName6,VarName7,x1q,'pchip');
pd = fitdist(VarName6, 'Exponential');
y1p = pdf(pd,x1q);
plot(VarName6,VarName7,'xr', x1q, y1p, '-r ', 'DisplayName', '5V Sample 1')

Accepted Answer

Cris LaPierre
Cris LaPierre on 4 Apr 2019
If you have an idea of what your fit equation is, use fittype and fit (curve fitting toolbox).
ft = fittype('a.*(1-r).^x',...
'coefficients',{'a','r'})
myfit = fit(VarName6,VarName7,ft,'StartPoint', [0.5 .95] )
hold on
plot(myfit)
myfit =
General model:
myfit(x) = a.*(1-r).^x
Coefficients (with 95% confidence bounds):
a = 0.512 (0.3657, 0.6583)
r = 0.9807 (0.9541, 1.007)
expDecay.png

More Answers (0)

Categories

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

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!