large files, very slow editor, no fix?
Ältere Kommentare anzeigen
Changes to the editor in R2011 have dramatically slowed down the editor when working with large m-files (e.g. 1000's of lines). I have been in correspondence with support staff, who tell me to disable cell mode and break up the file into smaller files.
Disabling cell mode does help somewhat, but there is still a lot of latency while typing. It can be several seconds to see what was typed. Even scrolling is choppy.
So the next step is break up the large file. But here's the problem. Most of the functions within the file are nested functions, which share the scope of the parent functions. How do I move the nested functions to separate files and maintain the behavior of nested functions?
Akzeptierte Antwort
Weitere Antworten (5)
Andrew Drake
am 27 Aug. 2013
1 Stimme
put "exit" on the first line
1 Kommentar
Scott
am 27 Aug. 2013
Oleg Komarov
am 12 Aug. 2011
0 Stimmen
By moving the nested functions to separate files you will:
- Lose the ability to see the parent's function workspace
- Other functions will see them and you may get into conflicts
To solve 1. you have two options:
- Add inputs to your ex-nested functions (no big news here).
- [STRONGLY UNRECOMMENDED] Hardcode assignin calls.
4 Kommentare
Scott
am 12 Aug. 2011
Oleg Komarov
am 12 Aug. 2011
Because you have to hardcode the names and if you change the name inside your main function (very likely to happen, I change names continuosly) then good luck extending the change to the private functions.
Another solution is to use subfunctions, you won't have to manage 50 files and the scope is limited to the main function. Don't know though if cell mode will give you problems, but worth giving it a try. You could save all the relevant variables in a struct and pass a single variable to the subfunctions...but again it is a sort of hardcoding.
Scott
am 12 Aug. 2011
Michael Katz
am 12 Aug. 2011
If the latency is related to the code structure, using subfunctions would help, as the editor needs more power to process deeper into nested code. Without seeing the code, it's hard to make a good judgement, but if the nesting is several levels deep, maybe it can be rewritten to use fewer levels. Also consider using a class object if that data has to be shared within that many function calls.
Daniel Shub
am 12 Aug. 2011
0 Stimmen
You could switch to an editor like emacs/vim.
You could move your nested functions to separate files. Then write another function that writes a new mfile that integrates your nested functions into the main function.
Divide your code up into smaller and reusable blocks. Use structures to efficiently pass the formerly nested functions arguments.
2 Kommentare
Scott
am 12 Aug. 2011
Daniel Shub
am 12 Aug. 2011
I don't use emacs with MATLAB, but more details can be found at:
http://blogs.mathworks.com/desktop/2009/09/14/matlab-emacs-integration-is-back/
and
http://matlab-emacs.sourceforge.net/faq.shtml
for more details ...
Would it use color to differentiate the various parts of the syntax? Yes
Would it flag syntax errors and make suggestions for correction? To some degree. It integrates with mlint.
Does it fold sections of code? I believe there are emacs plugings for this.
Autosave? Yes
Does it permit stepping through the code in debug mode, with the value of variables popping up when hovering over them? I am not sure on this one, but it looks like it.
Will it let me jump to the offending line of code after clicking on an error message? Yes
Andreas Goser
am 12 Aug. 2011
0 Stimmen
I know of a couple of examples where disabling cell mode completley healed the issue. Actually, I know only of one counter-example and this was a user who had his large MATLAB Code on an external server (mapped drive). If this is the case for you, please try putting the file local.
3 Kommentare
Scott
am 12 Aug. 2011
Andreas Goser
am 12 Aug. 2011
Well, it was worth a try...
Scott
am 12 Aug. 2011
per isakson
am 12 Aug. 2011
0 Stimmen
An object oriented design with methods in a separate @-folder should solve the problem with the editor.
Rewriting object oriented code, which is implemented with nested functions, might not be as bad as it sounds. I've done it a few times (for other reasons) with pre-R2008a m-files. At most a couple of thousand lines. However, it is certainly not a quick-fix.
Kategorien
Mehr zu Environment and Settings finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!