find intervals for both B and C which make the exponential function F converge to some points.
102 views (last 30 days)
Show older comments
BURCU
on 20 Nov 2024 at 18:50
Commented: BURCU
on 21 Nov 2024 at 5:59
I have series Y with 258 observations.
I define new series by deleting first and last 50 observations
newY = DlnY(51:end-50);
I also define the series Y lagged 2.
logY = log(Y);
DlnY = diff(logY);
Y2 = [NaN; NaN; DlnY(1:end-2)];
I have exponential function as follows:
F = 1- exp((-B/0.009)*(Y2-C)^2)
F_func = @(B, C, Y2) 1 - exp((-B / 0.009) * (Y2 - C).^2);
The parameter c is in the range of series newY.
C = [min(newY), max(newY)];
The parameter B in the interval from 1 to infinity.
B = [1, Inf];
I) I want to find intervals for both B and C which make the function F converge to 0.
II) I want to find intervals for both B and C which make the function F converge to 0.5.
III) I want to find intervals for both B and C which make the function F converge to 1.
How can I write a MATLAB code find these intervals?
Can you please help me to write these codes. Thank you.
6 Comments
Accepted Answer
Walter Roberson
on 20 Nov 2024 at 21:21
There is no point in calculating most of the F values since we are only interested in convergence. So we only test the last few values. The exact number we test is arbitrary.
F4_func = @(BC) 1 - exp((-BC(1) / 0.009) * (Y2(end-3:end) - BC(2)).^2);
targets = [0, .5, 1];
numtargets = length(targets);
bestBC = cell(numtargets,1);
for Tidx = 1 : numtargets
target = targets(Tidx);
objfun = @(BC) sum((F4_func(BC) - target).^2);
A = []; b = []; Aeq = []; beq = [];
lb = [1 min(newY)];
ub = [inf max(newY)];
nonlfunc = [];
BC0 = [2 mean(newY)];
bestBC{Tidx} = fmincon(objfun, BC0, A, b, Aeq, beq, lb, ub, nonlfunc);
end
3 Comments
Walter Roberson
on 20 Nov 2024 at 21:41
celldisp(bestBC)
would be more like it.
You could probably instead use
bestBC = zeros(numtargets, 2);
%...
bestBC(Tidx,:) = fmincon(...)
I just wasn't absolutely positive that fmincon() would return vectors of values even in the case where fmincon essentially failed.
More Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox 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!