How to do exponential curve fitting in the form of y=a*exp(-b*x)+ a constant

3 visualizzazioni (ultimi 30 giorni)
I have the following date
x=1:119
y=
11.45339775
12.78518772
11.98611355
12.25247192
12.78518772
10.92068195
13.31790447
9.322532654
11.71975613
11.98611355
11.98611355
10.65432358
10.92068195
11.71975613
10.65432358
12.5188303
11.98611355
11.45339775
12.5188303
12.5188303
10.92068195
12.25247192
14.91605282
10.12160683
9.855249405
15.18241119
11.71975613
12.5188303
14.91605282
15.71512699
9.855249405
14.38333702
11.45339775
12.5188303
11.18703938
12.5188303
13.31790447
12.5188303
13.31790447
13.85062027
13.31790447
10.65432358
12.5188303
14.91605282
12.25247192
13.31790447
14.11697865
11.45339775
13.0515461
12.5188303
13.58426189
14.38333702
9.855249405
11.71975613
13.0515461
11.71975613
11.45339775
13.31790447
11.98611355
14.38333702
13.0515461
14.91605282
11.71975613
14.38333702
14.64969444
13.58426189
12.5188303
13.0515461
14.91605282
13.58426189
15.98148537
13.0515461
14.38333702
16.51420212
11.45339775
12.25247192
10.3879652
15.18241119
10.92068195
14.91605282
14.38333702
12.25247192
10.65432358
13.58426189
10.65432358
13.31790447
15.44876862
12.25247192
12.78518772
13.58426189
13.0515461
13.31790447
14.64969444
14.11697865
13.85062027
14.11697865
13.0515461
11.98611355
14.11697865
14.11697865
14.38333702
13.31790447
14.64969444
11.71975613
14.38333702
14.64969444
14.38333702
13.0515461
15.44876862
12.5188303
15.18241119
15.44876862
13.0515461
14.64969444
12.25247192
13.85062027
13.31790447
13.58426189
13.31790447
10.65432358
7.990742683
9.588891029
10.3879652
12.78518772
11.18703938
9.855249405
9.056175232
9.855249405
10.65432358
9.855249405
11.18703938
10.12160683
I'd like to to have a curve fitting like y=a*exp(b*x) + a constant. I am wondering if someone could help me with this please! :)
Thanks
  1 Commento
KALYAN ACHARJYA
KALYAN ACHARJYA il 7 Ago 2019
Both are having different sizes??
>> whos x
Name Size Bytes Class Attributes
x 1x119 952 double
>> whos y
Name Size Bytes Class Attributes
y 132x1 1056 double

Accedi per commentare.

Risposte (2)

Star Strider
Star Strider il 7 Ago 2019
Note that ‘x’ and ‘y’ are not the same lengths, so this adjusts ‘y’ to correct for that:
yt = y(1:numel(x)); % Trim ‘y’ To Match ‘x’
objfcn = @(b,x) b(1).*exp(b(2).*x)+b(3);
B = fminsearch(@(b) norm(yt - objfcn(b,x(:))), rand(3,1));
figure
plot(x, yt, 'p')
hold on
plot(x, objfcn(B,x), '-r')
hold off
grid
producing:
B =
6.196520631377196
0.002516305503884
5.724451530242829
and the plot.

John D'Errico
John D'Errico il 7 Ago 2019
Sigh. You give us x as:
x = 1:119;
Then a vector y, of length 132.
Since x was so simply created, I'll assume it is just 1:32 to match that y vector. PLOT YOUR DATA. THINK!!!!!!!
plot(1:132,y,'o')
untitled.jpg
If what you see does not make sense, then think harder. Does that model even remotely allow you to fit that data? NO!
Here is the model you suggest.
y=a*exp(-b*x)+ c
Are you kidding? Seriously? If you think it does, then think again. And, then, think harder. Just for kicks, think about what a exponential looks like:
fplot(@(x) exp(-x))
untitled.jpg
Now, does the curve I drew look even remotely like the data in your plot? (NO!) Those constants in the model do not change the fundamental shape of the curve. They just stretch it out, scale it, raise it up or down, etc.
So, while you COULD use a curve fitting tool to estimate parmeters for that model to that data, the result will be utterly meaningless crapola. Complete computer generated drivel.

Community Treasure Hunt

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

Start Hunting!

Translated by