How initial value of solution can be provided for system solving by fsolve ?
Afficher commentaires plus anciens
I am trying to solve the set of equations using commands shown below
x0 = [-1 -1 -1 -1 2 2.5]
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(@calc,x0,options)
function F = cal(x)
F = [x(1)*cos(2*pi*D*q1) + x(3)*sin(2*pi*D*q1) - x(2)*cos(2*pi*D*q2) - x(4)*sin(2*pi*D*q2) + (q2^2*x(5)/(q2^2-1))*sin(2*pi*D+x(6)) - (1/(k+1));
x(1) - x(2)*cos(2*pi*q2) - x(4)*sin(2*pi*q2) + (q2^2*x(5)/(q2^2-1))*sin(x(6)) - (1/(k+1));
-q1*x(1)*sin(2*pi*D*q1) + q1*x(3)*cos(2*pi*D*q1) + q2*x(2)*sin(2*pi*D*q2) - q2*x(4)*cos(2*pi*D*q2) + (q2^2*x(5)/(q2^2-1))*cos(2*pi*D+x(6));
x(3)*q1 + x(2)*q2*sin(2*pi*q2) - x(4)*q2*cos(2*pi*q2) + (q2^2*x(5)/(q2^2-1))*cos(x(6));
2*pi*(k/(k+1))*(1-D) + x(5)*(cos(2*pi*D+x(6))-cos(x(6)))*((q2^2/(q2^2-1))-(k+1)) + (x(2)/q2)*(sin(2*pi*D*q2)-sin(2*pi*q2)) + (x(4)/q2)*(cos(2*pi*q2)-cos(2*pi*D*q2));
(k/(k+1)) + x(5)*sin(x(6))*((q2^2/(q2^2-1))-(k+1)) - (x(2)*cos(2*pi*q2)+x(4)*sin(2*pi*q2))];
end
However on running it is showing following error
Attempt to execute SCRIPT calc as a function: C:\Users\PE LAB\Desktop\calc.m
Error in fsolve (line 230) fuser = feval(funfcn{3},x,varargin{:});
Error in calc (line 4) [x,fval] = fsolve(@calc,x0,options)
Caused by: Failure in initial objective function evaluation. FSOLVE cannot continue.
Is there any problem with initialization?
(System is solvable with one case of parameter value q1=2; D=0.375; k=0.867; q2=2.9349; having solution as [−0.94 -0.86 -1.24 -1.23 1.92 2.57])
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Systems of Nonlinear Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!