You have provided very few information, such that the readers have to guess. My idea:
You have defined "det" as a variable before:
X = randi([1, 100], [3, 3]);
det = ones(2, 2);
Check this by typing into the command window:
Then run the code again and when it stops, check what "det" is:
If this is the problem, the solution is easy: Do not shadow built-in functions by local variables.