Dear all, I am trying to solve a system of 4 nonlinear equations. I act as below:
Creat a file as : equationssystem.m
The content of file is:
function F = equationssystem(x)F = [x(1)*x(2)^2+1314232.96*x(1)-2292.8*x(1)*x(2)+x(3)*x(2)-1146.4*x(3) ... -0.0004677*x(2)^2+0.6711*x(2)-158.14;... 2*x(1)*x(2)-2292.8*x(1)+x(3)-0.0009124*x(2)+0.6382;... x(1)*x(4)^2+1314232.96*x(1)-2292.8*x(1)*x(4)+x(3)*x(4)-1146.4*x(3) ... -0.001071*x(4)^2+1.939*x(4)-819.55;... 2*x(1)*x(4)-2292.8*x(1)+x(3)-0.002141*x(4)+1.941];end
Then in command window, I write:
x0 = [0; 1200; -1; 1100]; options = optimoptions('fsolve','Display','iter'); [x,fval] = fsolve(@equationssystem,x0,options)
The initial guesses are close to the real results. But I am facing these errors:
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in equationssystem (line 8)
F = [x(1)*x(2)^2+1314232.96*x(1)-2292.8*x(1)*x(2)+x(3)*x(2)-1146.4*x(3) …
Error in fsolve (line 219)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
I would really appreciate that if somebody help me to fix these errors and solve my equations since I have a huge sets of coefficients for which I have to solve these equations and I am a beginner in matlab.
Best Answer