Reputation: 11
i must calculate an F(x,k)=0
function 200 times.
Each time with a different k parameter value.
F is a nonlinear function, so i'm trying to use fsolve.
I'm not able to pass the k parameter value to the anonymous function used for the fsolve call.
The code i use is the following :
[x,fval,exitflag,output,jacobian] = fsolve(@(x)nucom,x0,options)
where ''nucom'' is the function F that must be zero.
How do i pass k?
Using @(x,k)
syntax some error incomes.
Upvotes: 1
Views: 944
Reputation: 2519
Assuming nucom takes k
as an argument, your syntax should be something like:
xsolved=zeros(1,200);
for k=1:200
[x,fval,exitflag,output,jacobian]=fsolve(@(x)nucom(x,k),x0,options);
xsolved(k)=x;
end
Upvotes: 2