|
On 3 Feb., 07:55, "Gregory " <thr33z3...@gmail.com> wrote:
> Hey all,
> I'm fairly new here so bear with me. I'm also pretty bad at matlab, just starting.
> I'm trying to find values for unknowns. There are 19 equations and 19 unknowns but fsolve seems to give me an error such as this:
>
> fsolve stopped because the problem appears regular as measured by the gradient,
> but the vector of function values is not near zero as measured by the
> default value of the function tolerance.
>
> Here is the function I'm using:
>
> function psi = Ufun(s)
>
> n = 19;
> i = 1:n;
> s = zeros(1,19);
>
> xi = i/(n+1);
> xi(20) = 0;
>
> yi = (0.18/0.2) .* (0.2969.*sqrt(xi) - ...
> 0.126.*xi - 0.3516.*(xi.^2) + 0.2843.*(xi.^3) ...
> - 0.1015.*(xi.^4));
>
> for j = 1:n
> for i = 1:n
> if xi(i) == xi(j)
> psiU(i) = 0;
> else
> psiU(i) = s(i) .* atan((yi(i) - yi(j)) ./ (xi(i) - xi(j)));
> end
>
> psi(j) = sum(psiU) + yi(j);
> end
> end
>
> end
>
> And here is the fsolve part:
> sz = ones(1,19);
> s = fsolve(@Ufun,sz)
>
> So can anyone help me out in figuring out why fsolve wouldn't give me any values for s? There are multiple ways of going about writing the function but I figured this is the easiest way.
fsolve tries to determine a vector s such that psi(s) = 0.
In the iteration process, fsolve wants you to evaluate your
function phi for a number of suggestions for the vector s in
order to get information on how to change s in order to
decrease |phi(s)|.
So why do you set the suggested values for s to zero in the line
> s = zeros(1,19);
?
Best wishes
Torsten.
|