What is wrong with RMS and Maximum delay spread Matlab code?
Not an answer but some guidance how to post this type of questions which is too long for a comment (@mods: feel free to delete if that's inappropriate).

We typically don't debug code. Focus on algorithmic questions. If possible ask about equations, not the implementation of the equations in code.
Define your terms (like &quot;maximum delay spread&quot;) using an external reference or preferably with an equation to make sure we are all talking about the same thing.
If you use an equation (which you should), define all symbols used in the equation.
If you post code, make sure it can be run. We don't have your data file so we can't really reproduce your problem.
Do basic debugging first yourself: Run your code with the most simple signal with a known answer. Once that runs ok, add more complicated signals ( but still with a known answer). Only after this is all working, proceed to unknown signals and answers
If you still have a problem, please post why you think this is. What is the answer you expect and why? What is the answer that you are getting and how is different from your expectation? Why does the problem doesn't seem to appear on the basic debugging signals you have used in step 5.