The MATLAB editor automatically highlights all content after %%
comments, and text after %%
in the same line are turned bold. But what's the essential difference here? Why do people sometimes use %%
instead of %
?
In the Editor, a section begins with two percent signs ( %% ). The text on the same line as %% is called the section title. Including section titles is optional, however, it improves the readability of the file and appears as a heading if you publish your code.
One percent sign ( % ) is used for commenting lines. Two percent signs ( %% ) have a different purpose: they are used for dividing your code into sections, which can be run independently.
From a syntax point of view, they are both comments.
In the Matlab editor, Matlab parses %%
delimited blocks as "sections" which you can run as a unit independent of running the whole script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With