First before getting into the problems in the code itself, you have created a new variable SUM that aliases the builtin Matlab function of the same name. While you've done this in the function Fitt() so it will go out of scope when the function exits and not have a global alias of the name, if you were to use the sum() function internal to that program you would get unexpected results. It's good practice to avoid in general regardless of scope.
function mysum =Fitt(x)
inp =QECsimull(net1,net2,t1s,t2s,x);
...
mysum=T;
...
OK, on to your problem -- Matlab variables are in scope in the workspace or in functions unless GLOBAL (or nested functions which aren't present here). So, while you've not given enough code to tell for certain, it's likely the variables net1 net2 t1s t2s are local variables in a calling function or the workspace and so are not visible within the function Fitt().
To fix this you would have to(+) add them to the argument list in the function definition and then pass them in the call.
(+) While it is possible to make them GLOBAL this is poor practice for code maintainability and reliability so is strongly discouraged as a practice in almost all cases.
Best Answer