Don't define a variable named rank, certainly not if you ever intend to use the FUNCTION named rank. This is why you get the subscript indices problem.
Similarly, when you use rank(D), MATLAB sees the result is symbolic array. But you cannot index using a symbolic variable. Again the problem is DON'T NAME A VARIABLE RANK. The same applies to variables named sum, mean, etc.
Try this:
What does it tell you?
Best Answer