You haven't provided enough info to run your code or to know the sizes of the input data, so I will venture two guesses,
- You are applying fminsearch to a function called fun2 which is defined nowhere in the code that you've shown.
- You are trying to minimize over too many parameters. FMINSEARCH is only guaranteed theoretically to converge for one unknown parameter, and empirically tends to work for up to about 6 parameters.