Hello I have an equation
i=a*exp(-b*x*38.94)+c*exp(d*x*38.94)
and b and d have know range of 0 to 1. There are 101 sets of data points which are
i=[1.60E+00
1.52E+00
1.44E+00
1.36E+00
1.28E+00
1.20E+00
1.12E+00
1.04E+00
9.54E-01
8.73E-01
7.92E-01
7.11E-01
6.30E-01
5.48E-01
4.67E-01
3.86E-01
3.05E-01
2.23E-01
1.42E-01
6.00E-02
-2.18E-02
-1.04E-01
-1.87E-01
-2.70E-01
-3.54E-01
-4.40E-01
-5.29E-01
-6.20E-01
-7.17E-01
-8.23E-01
-9.42E-01
-1.09E+00
-1.28E+00
-1.61E+00
-2.59E+00
-1.52E+00
-1.23E+00
-1.05E+00
-9.04E-01
-7.85E-01
-6.78E-01
-5.78E-01
-4.84E-01
-3.93E-01
-3.04E-01
-2.16E-01
-1.30E-01
-4.40E-02
4.15E-02
1.27E-01
2.12E-01
2.97E-01
3.81E-01
4.66E-01
5.51E-01
6.35E-01
7.20E-01
8.05E-01
8.89E-01
9.74E-01
1.06E+00
1.14E+00
1.23E+00
1.31E+00
1.40E+00
1.48E+00
1.57E+00
1.65E+00
1.73E+00
1.82E+00
1.90E+00
1.99E+00
2.07E+00
2.16E+00
2.24E+00
2.33E+00
2.41E+00
2.50E+00
2.58E+00
2.67E+00
2.75E+00
2.83E+00
2.92E+00
3.00E+00
3.09E+00
3.17E+00
3.26E+00
3.34E+00
3.43E+00
3.51E+00
3.60E+00
3.68E+00
3.76E+00
3.85E+00
3.93E+00
4.02E+00
4.10E+00
4.19E+00
4.27E+00
4.36E+00
4.44E+00]
x=[0:-0.01:-1]
how do I solve a, b, c and d using these 101 sets of data points?

 Accepted Answer

Stephan
Stephan on 11 Jun 2018
Edited: Stephan on 11 Jun 2018
Hi,
you could use
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub)
to solve this with the known bounds for b and d. When you define your problem this way:
fun = @(x,xdata)(x(1)*exp(-x(2)*xdata*38.94)+x(3)*exp(x(4)*xdata*38.94));
xdata = [0:-0.01:-1];
xdata = xdata';
lb = [-Inf 0 -Inf 0];
ub = [Inf 1 Inf 1];
x0 = [0 0 0 0];
ydata = [1.60E+00
1.52E+00
1.44E+00
1.36E+00
1.28E+00
1.20E+00
1.12E+00
1.04E+00
9.54E-01
8.73E-01
7.92E-01
7.11E-01
6.30E-01
5.48E-01
4.67E-01
3.86E-01
3.05E-01
2.23E-01
1.42E-01
6.00E-02
-2.18E-02
-1.04E-01
-1.87E-01
-2.70E-01
-3.54E-01
-4.40E-01
-5.29E-01
-6.20E-01
-7.17E-01
-8.23E-01
-9.42E-01
-1.09E+00
-1.28E+00
-1.61E+00
-2.59E+00
-1.52E+00
-1.23E+00
-1.05E+00
-9.04E-01
-7.85E-01
-6.78E-01
-5.78E-01
-4.84E-01
-3.93E-01
-3.04E-01
-2.16E-01
-1.30E-01
-4.40E-02
4.15E-02
1.27E-01
2.12E-01
2.97E-01
3.81E-01
4.66E-01
5.51E-01
6.35E-01
7.20E-01
8.05E-01
8.89E-01
9.74E-01
1.06E+00
1.14E+00
1.23E+00
1.31E+00
1.40E+00
1.48E+00
1.57E+00
1.65E+00
1.73E+00
1.82E+00
1.90E+00
1.99E+00
2.07E+00
2.16E+00
2.24E+00
2.33E+00
2.41E+00
2.50E+00
2.58E+00
2.67E+00
2.75E+00
2.83E+00
2.92E+00
3.00E+00
3.09E+00
3.17E+00
3.26E+00
3.34E+00
3.43E+00
3.51E+00
3.60E+00
3.68E+00
3.76E+00
3.85E+00
3.93E+00
4.02E+00
4.10E+00
4.19E+00
4.27E+00
4.36E+00
4.44E+00];
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub)
you wil get the vector x with:
x =
0.1152 0.0991 -0.2550 0.0000
which represents the values for a,b,c and d.
but consider that:
your xdata runs from
x=[0:-0.01:-1]
this is a direction which maybe correct in your case - but not the usual direction! if you execute the same code with
x=[-1:0.01:0]
which is the "natural" direction you get:
x =
-0.2550 0.0000 5.4618 0.0991
So you should try to find out in which direction your measured values run, to geht the correct result.
Best regards
Stephan

More Answers (0)

Categories

Tags

Asked:

on 11 Jun 2018

Edited:

on 11 Jun 2018

Community Treasure Hunt

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

Start Hunting!