fix J in costFunctionReg.m