MATLAB: Fsolve not enough input arguments

MATLABnonlinearsystem equations

Hello! Trying to get solution with the help fsolve, i see such problem:
Not enough input arguments.
Error in System (line 2)
F(1) = x(1)*[exp(x(4)/x(2)) - exp(-x(4)/x(3))] - 0.9;
Error in Work1 (line 8)
Coefficients = fsolve(System, x0)
The code is
clc, clear
x0 = [1, 1, 1, 1,1];
Coefficients = fsolve(System, x0)
function Coeffs = System(x)
F(1) = x(1)*[exp(x(4)/x(2)) - exp(-x(4)/x(3))] - 0.9;
F(2) = x(1)*[exp(-(x(4)-0.6*1.2e-6)/x(2)) - exp(-(x(4)-0.6*1.2e-6)/x(3))] - 0.3;
F(3) = x(1)*[exp(-50e-6/x(2)) - exp(50e-6/x(3))] - 0.5;
F(4) = x(1)*[exp(-x(5)/x(2)) - exp(-x(5)/x(3))] - 1;
F(5) = -x(1)/x(2)*exp(-x(5)/x(2)) + x(1)/x(3)*exp(-x(5)/x(3));
F(6) = 30e3*x(1)*(exp(-x(4)/x(2)-exp(-x(4)/x(3)))) - 30e3*x(1)*(exp(-(x(4)-0.6*1.2e-6)/x(2))-exp(-(x(4)-0.6*1.2e-6)/x(3)));
end

Best Answer

You need to supply System() as a function handle to fsolve(). The way you have written it, Matlab thinks you want to simply call the function System(), and supply the result to fsolve().
As far as I know, the script itself should not execute because you can't define functions within scripts.
clc, clear
x0 = [1, 1, 1, 1,1];
Coefficients = fsolve(@(x)System(x), x0)
In a separate file (also, it looks like your function "System" will also not return an output, so need to change the output name):
function F = System(x)
F = nan(1,6);
F(1) = x(1)*[exp(x(4)/x(2)) - exp(-x(4)/x(3))] - 0.9;
F(2) = x(1)*[exp(-(x(4)-0.6*1.2e-6)/x(2)) - exp(-(x(4)-0.6*1.2e-6)/x(3))] - 0.3;
F(3) = x(1)*[exp(-50e-6/x(2)) - exp(50e-6/x(3))] - 0.5;
F(4) = x(1)*[exp(-x(5)/x(2)) - exp(-x(5)/x(3))] - 1;
F(5) = -x(1)/x(2)*exp(-x(5)/x(2)) + x(1)/x(3)*exp(-x(5)/x(3));
F(6) = 30e3*x(1)*(exp(-x(4)/x(2)-exp(-x(4)/x(3)))) - 30e3*x(1)*(exp(-(x(4)-0.6*1.2e-6)/x(2))-exp(-(x(4)-0.6*1.2e-6)/x(3)));
end
I would also ask about the math problem, which looks over-specified...5 unknowns in 6 equations