When the script is started, it displays "Enter the number of Diversity" and expects an input. The range and type of valid inputs are not explained in the help text, such that the user has to examine the poorly documented code to see, what this number should represent at all.
Why do you measure the timings by TIC/TOC?
Instead of the loop, the command MAX() is much faster to determin the maximum.
Currently the purpose of the program is not clear.
Users beware! This is a script that destroys your current workspace.
To the author: you should write it as a function, allowing flexible inputs, with proper comments and a help section that explains the purpose of the function in detail.