help-octave
[Top][All Lists]

## Re: Must all coefficients for fsolve be numeric???????

 From: José Abílio Matos Subject: Re: Must all coefficients for fsolve be numeric??????? Date: Wed, 18 Mar 2020 18:24:46 +0000

```On Wednesday, 18 March 2020 17.24.53 WET Brett Green wrote:
> Y_e = cosh(Alpha*X_bar) - cos(Alpha*X_bar) + Eta*(sinh(Alpha*X_bar) -
> sin(Alpha*X_bar)); g = @(X) f(X,Y_e);
> [X, fval, info] =
> fsolve(@g,[0.1;0.01;1024;4.;-1.0;0.001;0.0;0.5;154.;71000;0.000007;0.000005
> ;
> 0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0
> ;0])

Just as Brett said. But you can skip the second step.

[X, fval, info] = fsolve(@(X) f(X,Y_e),
[0.1;0.01;1024;4.;-1.0;0.001;0.0;0.5;154.;71000;0.000007;0.000005;
0;
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0])

If you have more parameters you must pass them all as arguments of the f
function and than only let X be the only variable.

IMHO A simple variant of this is to create a structure as pass all the
parameters as members of the struct. Something like

par.Y_e
par.dStat
...

You need to define those member outside and then it should be enough to call
like above:
[X, fval, info] = fsolve(@(X) f(X,par),

The other option is to make the parameters that you use as global variables
but then do not forget to declare those variables as global in the function f:
https://octave.org/doc/v5.2.0/Global-Variables.html#Global-Variables

I hope that this helps,
--
José Matos

```