From: Thomas on
"Steven Lord" <slord(a)mathworks.com> wrote in message <gjs0cb$e03$1(a)fred.mathworks.com>...
>
> Splitting it up isn't that difficult a problem.
>
>
> x = fsolve(@myfunction7, [1; 1]);
> complexSolution = complex(x(1:2:end), x(2:2:end))
>
>
> where myfunction7 is:
>
>
> function y = myfunction7(x)
> complexX = complex(x(1:2:end), x(2:2:end));
> complexY = complexX.^2 + 1; % to solve x.^2 + 1
> y = [real(complexY); imag(complexY)];
>
>
> using an "interleaved" storage for x, the parameter for which FSOLVE solves,
> and [real; imaginary] for y, the output from myfunction7, the function to be
> solved.
>
> --
> Steve Lord
> slord(a)mathworks.com
>

When I try my example:

x = fsolve(@BetaZeroForRoot, [1.0, 1.0]);
ret = complex(x(1:2:end), x(2:2:end));

with:

function res = BetaZeroForRoot(x)
n = 1;
lambda = 1.064; % in mu
a = 8.5; % in mu
Ncore = 1.33;
Nclad = 1.45;

%%% dependent variables
k = 2*pi/lambda;
t2 = a^2 * k^2 * (Ncore^2 - Nclad^2);

X = complex(x(1:2:end), x(2:2:end));
Y = BetaZero(X,t2,n,Ncore,Nclad);
res = [real(Y), imag(Y)];
end

I get the following error message:

"??? Input argument "XDATA" is undefined.

Error in ==> sfdnls at 44
if ~isempty(XDATA)

Error in ==> trustnleqn at 109
[JACfindiff,numFDfevals] = sfdnls(x,Fvec,JACfindiff,group,[], ...

Error in ==> fsolve at 378
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msg]=...

Error in ==> test at 21
x = fsolve(@BetaZeroForRoot, [1.0, 1.0]);"

What does this mean?

Thomas