If this is a homework assignment, I'm guessing there may be at least one or two examples in your textbook where they walk through the steps of the algorithm, showing the result of each step. If that's the case, try running through that same example in your code using the debugging tools included in MATLAB. Check the result of each step of your code against the results your textbook says you should receive at that step. Once you've found a discrepancy, determine why the two sets of results differ.
If there is no such example in your textbook, either search online for "thomas algorithm worked example" or work through the steps yourself using pencil and paper (or marker and whiteboard, or other writing implement and writing surface.)
If this is not a homework assignment, consider just using the backslash operator \ instead.