Matlab is not recognizing sections %%
Show older comments
I am working with Matlab 2018a and for some reason Matlab stop recognizing my sections (%%). Maybe I did something after messing in Home>Preferences, but I'm not really sure. Has anyone had this problem before? I've look online and people say "Enable Cell Mode", but I have no idea how to do this in 2018a.
thanks in advance.
1 Comment
Reza Banaei
on 6 Jan 2022
Look for open sentences in your code. Something like
'output' ...
will break the sectioning.
Answers (4)
Steven Lord
on 18 Jun 2019
1 vote
Look for the message indicator in your file in the Editor. See the first picture on this documentation page for the location of the message indicator. Is it red? If so your code has a syntax error that would prevent it from running successfully, and if your code is not syntactically valid I believe MATLAB will not recognize your sections. Correct the problems that Code Analyzer has identified as red (error) issues and I expect the sections should resune working.
4 Comments
Blake Porter
on 18 Jun 2019
Hi Steven, I do not have any errors in the code and it all executes. I gave a more detailed description here: https://www.mathworks.com/matlabcentral/answers/467586-matlab-2018a-editor-no-longer-showing-code-sections
Federico Sansalone
on 22 Dec 2021
I solved it simply changing the name of the script file wich was containing spaces! (From "Capacity Problem.m" to "CapacityProblem.m").
ohad akler
on 31 Mar 2024
Federico answer works !
Steven Lord
on 31 Mar 2024
Yes, MATLAB program file names are not allowed to contain spaces. Otherwise, consider the example Federico Sansalone posted. If you had both "Capacity Problem.m" and Capacity.m, would "Capacity Problem" call the first of those functions with no inputs or the second of those functions with the char vector 'Problem' as input?
Arvind Sathyanarayanan
on 24 Jan 2019
0 votes
Did you turn-off the sections in the Autoformatting menu? 

2 Comments
Blake Porter
on 18 Jun 2019
I have the same issue and I have both section break options ticked. Restarted Matlab and computer did not help.
per isakson
on 7 Jan 2022
KIDKAWHI
on 17 Nov 2021
0 votes
welp we all stuck in this boat
3 Comments
Federico Sansalone
on 22 Dec 2021
I solved it simply changing the name of the script file wich was containing spaces! (From "Capacity Problem.m" to "CapacityProblem.m").
Marion Kreins
on 23 Dec 2021
thx, it worked :)
per isakson
on 23 Dec 2021
Edited: per isakson
on 23 Dec 2021
Spaces in mfile names are not allowed. The "message indicator" of R2018b indicates the error. It's red!
However, in my simple case R2018b still recognizes the sections.
Bruno Tremblay
on 3 Jun 2024
0 votes
This is a huge limitation of matlab. For instance when we debug, we may have part of the code that still "messy", and debugging of sections using %% is not possible until we have cleaned up the entire code.
Categories
Find more on Desktop in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!