code folding issue

9 views (last 30 days)
Ben Bowles
Ben Bowles on 2 May 2011
Hi there,
I've had some difficulties lately with code folding, specifically for cells. Using code folding for cells is useful as it allows me to breakup rather long scripts into various segments. In such cases, these segments contain various for and if and try loops.
A recent example script contains a sitaution where I had approximately 100 lines of code in one cell (with code folding working), and then a similar one right below it (also with code folding that was working). Then, below that, I would type:
%% please make new cell for me
And I would see no evidence of any code folding or any new cell creation.
There have been a few other situations of inconsistent activity I have seen with respect to code folding and cells (in particular with long scripts). Does anyone know what the soruce of this might be, and how I can write amy scripts in a way that would make this not happen?
Its worth noting that my script (from what I can see) has no major syntax errors (and there is an end statement wherever there is supposed to be one). Its also worth noting that at the beginning when I began to approach this issue, the first two cases of code folding weren't working either... I found that avoiding certain aspects of syntax seemed to help (such as avoiding one line for / end loops for example). I don't know why this helped.
It seems to be that code folding is a bit inconsistent and I might have to give up on it as a strategy for managing long scripts.
Thanks so much, Ben
  5 Comments
Ben Bowles
Ben Bowles on 2 May 2011
Thanks again, actually I think you understood well what I am trying to do.
So after some more fiddling, I believe I've isolated the issue. When i tried to write "%% new cell that doesn't work" (as above), no cell was created.
But, if I copy and paste the code elsewhere (in this box or in an MS document), and then copy and pasted it BACK into the editor, it now properly code folds the cell. I believe this must be a bug in Matlab.
Oleg Komarov
Oleg Komarov on 3 May 2011
I had cases like yours in the past but it's really hard to reproduce the same behaviour for others...then it's hard to detect and solve.

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!