This really should be asked on a different forum, as only barely about MATLAB, and a good answer requires teaching a class in statistics. That won't happen here.
I'll give you a quick intuitive answer, but then suggest you need to take a class in statics, or at least do some reading if you want more help.
Think of degrees of freedom as the amount of information content available in your data.
Suppose you have n data points. Every piece of data is one piece of information. (That some data points may be more valuable than others is food for yet another entire class in statistics.) But initially, n pieces of information.
Now, compute the mean. That is one parameter inferred from your data. But if you now try to compute the variance, you need to use the mean to compute the variance. So you had only n-1 pieces of information available to compute that variance.
If you look at the formula for a mean, what do you see?
mu = sum(X)/n
So add up all of your data, then divide by n, the degrees of freedom available.
However, the formula for the variance does what?
V = sum((X - mu).^2)/(n-1)
So you subtract off the mean, square everything, sum it up, but now divide by n-1. (There are all sorts of issues in this, as to why another formula will divide by n, when computing a population variance. Again, this is NOT a class in statistics.)
Sorry, but if you want a better answer, time to do some serious readng, or take a class.