Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between % and %% for comments?

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 %?

like image 935
OneZero Avatar asked Jul 08 '13 15:07

OneZero


People also ask

What is %% in Matlab?

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.

What does double Percent sign mean in Matlab?

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.


1 Answers

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.

like image 197
Prashant Kumar Avatar answered Oct 04 '22 18:10

Prashant Kumar