- #1
dRic2
Gold Member
- 890
- 225
Here's what I have to do:
1) I arbitrary give a first value to the variable ##x_b##. Let's say ##x^{(0)}_b = 0.3##
2) I find ##x_D## by evaluating this integral:
$$ln(\frac {52.32} {100}) = \int_{0.5}^{x^{(0)}_b} \frac {dx} {x^{(0)}_D - x}$$
3) I use the value I got for ## x^{(0)}_D## to evaluate ##y^{(0)}_n##
$$y^{(0)}_n = f(x^{(0)}_D, x^{(0)}_b)$$
4) I check if ##x^{(0)}_D - y^{(0)}_n = 0## then I stop, otherwise I have to choose an other ##x^{(1)}## and start iterating again.
In matlab:
and I call this with:
I keep getting a warning that the integral my not exist and fsolve won't start...
Any help?
1) I arbitrary give a first value to the variable ##x_b##. Let's say ##x^{(0)}_b = 0.3##
2) I find ##x_D## by evaluating this integral:
$$ln(\frac {52.32} {100}) = \int_{0.5}^{x^{(0)}_b} \frac {dx} {x^{(0)}_D - x}$$
3) I use the value I got for ## x^{(0)}_D## to evaluate ##y^{(0)}_n##
$$y^{(0)}_n = f(x^{(0)}_D, x^{(0)}_b)$$
4) I check if ##x^{(0)}_D - y^{(0)}_n = 0## then I stop, otherwise I have to choose an other ##x^{(1)}## and start iterating again.
In matlab:
Code:
function out = my_int(xD, xB)
fun = @(xD) 1./(xD - x)
out = log(52.32/100) - integral(fun, 0.5, xB);
end
function out = system(xb)
find_xD = @(xD_) my_int(xD_, xb);
xD = fzero(find_xD, 0.7);
% other lines of the code
% where I calculate y_n
out = y_n - xD;
end
and I call this with:
Code:
fsolve(@system, 0.3);
I keep getting a warning that the integral my not exist and fsolve won't start...
Any help?
Last edited: