MATLAB: How to replace symbolic variables to solve a nonlinear system using fsolve

fsolvenonlinear equationssystem of equations

I am working on a system of nonlinear equations, for example:
3*u1^2 + 2*u2 – 5 = 0;
4*u1 – 3*u2^3 + 10 = 0;
where u1 and u2 are symbolic variables. I'm having much difficulties replacing u1 and u2 with x(1) and x(2) in @fun, suitable for fsolve:
x = fsolve(fun,x0,options)
The problem is that the system of equations (and number of variables) is too large to do this manually … Is anyone aware of an elegant/automatic solution?

Best Answer

1 first writte this function and save it "answerf90"
function y=answerf90(u)
y(1)=3*u(1)^2 + 2*u(2) - 5 ;
y(2)=4*u(1) - 3*u(2)^3 + 10 ;
2 second
fsolve(@answerf90,[0;0]) % [0;0] your initials conditions