Excellent work! I agree with the comment that the use of i and j of variables should be avoided altogether (because i and j are used to work with complex numbers) and to start iterators with k. But that's the only fault I find. I've been using a lot of this for years, but there's still some useful new insights here as well.
Asan, this is a unit testing framework to help ensure your MATLAB programs have been written correctly and to prevent changes from introducing bugs. There is now a unit test framework included in MATLAB, and you may be interested in the following blog post describing how someone can use such a framework to ensure the quality of science & engineering:
I tried to understand 'MATLAB xUnit Test Framework' from description but unfortunately the most part I couldn't understand, can tell me is useful for what in more simple way, sorry I'm new user of MATLAB