This is a script file not a function. It opens files named "connectivity.xls", "partition1.xls", and "partition2.xls", reads some undisclosed data, then does some unidentified actions on the data. Many For loops are used to avoid vectorization. There are no comments other than some unhelpful lines at the top of the file identifying the author. Author, please remove this file as it useless to anyone but you its current state. Why post something no one else can make use of?
Can't comment the algorithm per se, but:
1) Package your algorithm in a FUNCTION, and document you input thoroughly.
2) Scripts can be used for making a demo, but NEVER EVER issue a 'clear all' command in the script.
3) An example or two makes a program so much easier to understand.