Fit data to an exponential curve using fitdist
3 views (last 30 days)
Show older comments
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')
0 Comments
Accepted Answer
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)
0 Comments
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!