Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put comment in a line-continuation [duplicate]

Tags:

matlab

I have some function like this:

result = myfunc(arg1, ...
                arg2, ...
                arg3);

I wish to comment out arg2 and put in something else:

result = myfunc(arg1, ...
         %      arg2, ...    <-- I get a red squiggly underline at the last dot
                arg2b, ...   <-- and under arg2b
                arg3);       <-- and under the closing parenthesis

But matlab won't let me put a comment in a line continuation, and all my Google searches turn up either multi-line statements, or multi-line comments, but not comments in a multi-line statement.

The error is "Parse error at : usage might be invalid Matlab syntax".

Is there a way to do this?

In reality the arguments are long filenames with full paths, and moving them up and out of the way makes the code really unreadable.

like image 416
Sonicsmooth Avatar asked May 27 '16 19:05

Sonicsmooth


People also ask

How do I add a comment to a single line?

To add a single-line comment, just hold down the combo of keys shown above inside the code editor. Then the whole line you're on will be commented out. Just keep in mind that since everything will be commented out on that line, this only works for single-line comments.

Can a comment span more than one line?

It can span multiple lines. And it can even contain HTML! <p> This is a paragraph inside a multi-line comment. </p> --> Keep in mind that if you use multi-line comments, you will have to make sure you use the --> tag to close the comment. If you don't, the rest of the markup will be ignored and potentially break your page.

What is a continuation line in a sentence?

Any sentence, entry, clause, or phrase that requires more than one line can be continued in Area B of the next line that is neither a comment line nor a blank line. The line being continued is a continued line; the succeeding lines are continuation lines. Area A of a continuation line must be blank.

How do you write a continuation line for a literal?

If an alphanumeric or national literal that is to be continued on the next line has as its last character a quotation mark in column 72, the continuation line must start with two consecutive quotation marks. This will result in a quotation mark as part of the value of the literal.


1 Answers

To comment out part of a statement that spans multiple lines, use an ellipsis (...) instead of a percent sign. For example,

result = myfunc(arg1, ...
            ... arg2, ...
                arg2b, ...
                arg3);
like image 135
wim Avatar answered Oct 01 '22 03:10

wim