Of course writing such a huge M-file in Matlab's editor is slow. It is expected to be. Note that the editor performs a syntax check after all changes, can highlight code blocks, variables, checks if opening and closing brace, brackets or parenthesis have to be highlighted, checks the indentation of for and while loops and let MLint check the validity and efficiency of the code.
Functions or even worse scripts with more than 1000 lines of code are hard to read and to maintain. It gets horrible to debug this code and you cannot apply unit tests to parts of it. Therefore the complexitiy of the code will be such high, that an exhaustive testing is impossible. In consequence no serious programmer would use such code, but delete it without any further investigations.
Split the code to subfunctions. This will improve the editing, maintenance and perhaps even the runtime.