Search the forum and you will find many answers, see e.g. [? Error using ==> chol Matrix must be positive definite)