Code Sections disappeared. Cannot use %%

I closed MATLAB and when I re-opened it, all my code sections were gone. I had previously enabled code folding around code sections as well and I can no longer do this.
For example, I have a code which has:
A=10;
B=20;
C=A+B;
D=A*B;
Previously, I could fold up the first section and run it separately from the second section. Now these code sections have disappeared. Any help or info is greatly appreciated.
I also cannot fold up my for, if, while statements etc. I have checked in Preferences and Code Folding is enabled.

1 件のコメント

Tobe freeman
Tobe freeman 2015 年 6 月 12 日
Me, too! It's been flakey for ages. I am a little disappointed that there is nothing about this bug on Matlab central - or stackoverflow etc.

サインインしてコメントする。

 採用された回答

Christopher Buchanan
Christopher Buchanan 2017 年 2 月 15 日

4 投票

It sounds like MATLAB hasn't been able to parse the entire .m file - I had a similar issue until I realised one of my if/for statements hadn't been terminated with an 'end'...maybe until MATLAB is able to parse everything completely it doesn't know how to interpret context-sensitive markers like code folders and section breaks.

5 件のコメント

Ryan Romeo
Ryan Romeo 2017 年 10 月 25 日
Wow, thank you so much! I couldn't for the life of me figure out what was wrong. After reading your comment, I realized I lost my UI markers after I had initiated a for loop and hadn't yet terminated it. Didn't think that they were correlated...
Kunxun Qian
Kunxun Qian 2018 年 9 月 19 日
Made the same mistake, and thank you Chris!!!
Ang Ji
Ang Ji 2019 年 1 月 18 日
Thanks Chris! I terminated and it works.
CHEN YU-AN
CHEN YU-AN 2021 年 3 月 2 日
Thanks, it is really helpful
Jordi
Jordi 2025 年 7 月 11 日
Note that having text after line continuations (...) may also result in MATLAB not being able to parse the entire .m file.
See e.g. https://nl.mathworks.com/matlabcentral/answers/2161765-code-folding-is-broken-can-t-see-hundreds-of-lines-of-code-in-editor#comment_3337221

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2015 年 3 月 9 日

コメント済み:

2025 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by