Matlab is not recognizing sections %%

88 次查看(过去 30 天)
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 个评论
Reza Banaei
Reza Banaei 2022-1-6
Look for open sentences in your code. Something like
'output' ...
will break the sectioning.

请先登录,再进行评论。

回答(4 个)

Steven Lord
Steven Lord 2019-6-18
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 个评论
Steven Lord
Steven Lord 2024-3-31
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
Did you turn-off the sections in the Autoformatting menu? MA.png
  2 个评论
Blake Porter
Blake Porter 2019-6-18
I have the same issue and I have both section break options ticked. Restarted Matlab and computer did not help.

请先登录,再进行评论。


KIDKAWHI
KIDKAWHI 2021-11-17
welp we all stuck in this boat
  3 个评论
per isakson
per isakson 2021-12-23
编辑:per isakson 2021-12-23
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
Bruno Tremblay 2024-6-3
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.

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by