How I can add an exponential fit to my cdfplot?

1 view (last 30 days)
Hi there,
I have data to be used in a cdfplot as shown below, if I want to add on the plot an exponential fit to the data, what do I need to do, and what is the growth constant of that exponentional
Thanks in advance
z=[
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.1000
7.2000
7.7000
8.2000
8.8000
9.0700
9.7600
11.2200
11.2200
11.4000
11.6000
11.8000
12.3000
12.8500
13.3000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.6000
15.6000
15.6000
15.6000
15.6000
15.7000
15.8000
16.2000
16.2000
16.5000
16.6000
16.6000
16.6000
16.6800
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
17.0600
17.3000
17.6000
17.6000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7700
17.8000
18.2000
18.2900
18.3200
18.3300
19.5400
20.6000
20.8400
21.1000
24.1000
24.4000
25.6000
26.4000
26.5000
26.5000
26.5000
26.5000
26.5000
26.5400
26.5700
27.0000
27.1000
28.0000
28.0300
29.3800
30.0000
30.0000
30.0000
30.0000
30.0000
31.0000
31.0000
31.0000
31.0000
31.0000
31.1000
31.1000
31.1000
31.1000
31.1000
31.3000
31.4000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3200
33.3500
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
34.0900
34.7000
38.3800
38.4000
39.0200
42.1000
42.1000
42.2000
42.2000
42.2000
42.3000
43.3000
43.3200
43.3500
43.4000
43.4000
43.4000
45.0000
45.0000
45.0000
45.1000
45.1000
48.0000
49.4000
53.1000
53.2000
53.2000
53.2400
53.2700
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7300
65.7000
65.8000
65.8200
66.3000
70.2000
70.2000
70.3000
70.3000
70.3000
70.3400
70.5000
72.2000
74.0000
77.3000
77.5000
77.6000
78.0000
89.6000
90.0000
90.0000
90.3000
90.3000
113.0000
113.0000
113.3000
113.3000
113.6300
203.0000
203.3700
203.4000
203.4000
203.4000
203.7000
203.7000
203.7000
203.7000
204.0000
204.0400
];
cdfplot(z)

Accepted Answer

Davide Masiello
Davide Masiello on 23 Sep 2022
I guess you could do something like this
load z
x = linspace(0,1,length(z));
fitfunc = fittype(@(A,B,C,x) A*exp(B*x.^C));
x0 = [10 10 0.5];
f = fit(x',z,fitfunc,'StartPoint',x0)
f =
General model: f(x) = A*exp(B*x.^C) Coefficients (with 95% confidence bounds): A = 11.04 (9.03, 13.04) B = 2.965 (2.789, 3.142) C = 3.294 (2.903, 3.685)
coeffvals = coeffvalues(f)
coeffvals = 1×3
11.0363 2.9653 3.2940
plot(f(x),x,'-r',z,x,'b.')
legend('fitted curve','data')
  6 Comments
Torsten
Torsten on 23 Sep 2022
Edited: Torsten on 23 Sep 2022
z=[
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.1000
7.2000
7.7000
8.2000
8.8000
9.0700
9.7600
11.2200
11.2200
11.4000
11.6000
11.8000
12.3000
12.8500
13.3000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.5000
15.6000
15.6000
15.6000
15.6000
15.6000
15.7000
15.8000
16.2000
16.2000
16.5000
16.6000
16.6000
16.6000
16.6800
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
16.7000
17.0600
17.3000
17.6000
17.6000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7000
17.7700
17.8000
18.2000
18.2900
18.3200
18.3300
19.5400
20.6000
20.8400
21.1000
24.1000
24.4000
25.6000
26.4000
26.5000
26.5000
26.5000
26.5000
26.5000
26.5400
26.5700
27.0000
27.1000
28.0000
28.0300
29.3800
30.0000
30.0000
30.0000
30.0000
30.0000
31.0000
31.0000
31.0000
31.0000
31.0000
31.1000
31.1000
31.1000
31.1000
31.1000
31.3000
31.4000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3000
33.3200
33.3500
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
33.4000
34.0900
34.7000
38.3800
38.4000
39.0200
42.1000
42.1000
42.2000
42.2000
42.2000
42.3000
43.3000
43.3200
43.3500
43.4000
43.4000
43.4000
45.0000
45.0000
45.0000
45.1000
45.1000
48.0000
49.4000
53.1000
53.2000
53.2000
53.2400
53.2700
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7000
56.7300
65.7000
65.8000
65.8200
66.3000
70.2000
70.2000
70.3000
70.3000
70.3000
70.3400
70.5000
72.2000
74.0000
77.3000
77.5000
77.6000
78.0000
89.6000
90.0000
90.0000
90.3000
90.3000
113.0000
113.0000
113.3000
113.3000
113.6300
203.0000
203.3700
203.4000
203.4000
203.4000
203.7000
203.7000
203.7000
203.7000
204.0000
204.0400
];
x = linspace(0,1,length(z));
fitfunc = fittype(@(B,C,x) 0.25*exp(B*x.^C));
x0 = [10 0.5];
f = fit(x',z,fitfunc,'StartPoint',x0)
f =
General model: f(x) = 0.25*exp(B*x.^C) Coefficients (with 95% confidence bounds): B = 6.609 (6.56, 6.658) C = 0.9425 (0.8716, 1.013)
coeffvals = coeffvalues(f)
coeffvals = 1×2
6.6089 0.9425
plot(f(x),x,'-r',z,x,'b.')
legend('fitted curve','data')
Hozifa
Hozifa on 23 Sep 2022
@Torsten, thank you very much, I am really in your debt

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!