Solve nonlinear equation system with parameter in Matlab

83 Views Asked by At

How to modify the code if I add parameter c to function Thank for help

x0 = [0,0];
x = fsolve(@myfunc,x0)
%===================
function F = myfunc(x)
F(1) = 4*c*(c*x(1) - 2)^3 + 2*c*x(2)^2 *(c*x(1)-2);
F(2) = 2*x(2)*(cx(1) - 2)^2 + 2*(x(2)+1);
end
1

There are 1 best solutions below

3
Aksen P On
  1. Change the function line as following: function F = myfunc(x, c)
  2. Change x execution part:
x = fsolve(@(x) myfunc(x, c), x0)
  1. Create a new function x(c):
function x = x_func(c)
    x0 = [0,0];
    x = fsolve(@(x) myfunc(x, c), x0);
end
  1. Use your inputs:
c = 6;
x = x_func(c);
x1 = 2/c;
x2 = -1;