Hi, I write an objective function in both m-file (fileA1.m) and C mex file (fileA2.c). Given an input to this objective function, computation time in C mex file is 15 times faster than that of m- file. However, when i use the objective function in function lsqnonlin of Matlab, computation time which lsqnonlin gets a optimal solution is almost the same for both files (~101 minutes for C mex file and ~104 minutes for m-file). I hope when i use C mex file, i will save more time for optimization process, but it is not. Can you help me explain why lsqnonlin spends almost the same computation time? I would like to understand more how lsqnonlin of Matlab works to reduce its time? Thanks in advance!