restricting values of solution when solving for CDFs with fsolve

I am currently trying to solve for a system of CDFs which are linked to each other via 3 equations. I use fsolve for this. Is there any way to tell matlab that the solution to the equations must be between 0 and 1 at each point of my grid as it is a CDF?
Here's my code for the function that should be solved:
function A = root1d(F,i,g31,g32,g23,grid,lowerb,upperb)
for j =1:1:i
a(j) = g31(j)/((1-F(3,j))*F(2,j));
b(j) = g32(j)/((1-F(3,j))*F(1,j));
c(j) = g23(j)/((1-F(2,j))*F(1,j));
end
A(1) = F(1,i) - integrateEF(a,grid(1:i), lowerb,upperb);
A(2) = F(2,i) - integrateEF(b,grid(1:i), lowerb,upperb);
A(3) = F(3,i) - integrateEF(c,grid(1:i), lowerb,upperb);
end
integrateEF is a function I wrote to integrate over empirical functions:
function [ integralvalue, Fdist ] = integrateEF( empiricalF, grid, lower_limit, upper_limit )
grid(1) = -realmax;
Fdist = @(new_x) interp1(grid, empiricalF, new_x, 'previous', 'extrap');
integralvalue = integral(Fdist, lower_limit, upper_limit);
end
And here is how I call fsolve:
F0 = 0.1*ones(3,length(grid));
for i = 100:1:length(grid)
F(:,i) = fsolve(@(F)root1d(F,i,g31,g32,g23,grid,min(grid)-1,grid(i)),F0);
i
end
Thank you for your help!

Réponses (1)

Torsten
Torsten le 12 Avr 2018
If you substitute y = cos^2(x) and evaluate your equations with the y-vector, you will get a solution vector which is between 0 and 1.
Best wishes
Torsten.

Tags

Question posée :

le 11 Avr 2018

Community Treasure Hunt

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

Start Hunting!

Translated by