Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting in matlab [duplicate]

This sounds like a simple question. I have the following snippet:

target=strcat(string, ...
              string2, ...
              'suffix' );   

A simple string concatenation written in multi-line. There are times I have to comment out intermediate text i.e. string2 with %. However doing this gives an error message: parse error at ')': usage might be invalid matlab syntax. Can someone help me on commenting out the middle line with alternative forms?

like image 837
SKPS Avatar asked Jan 02 '26 05:01

SKPS


2 Answers

The line continuation command ... makes everything after it a comment, and (of course) makes MATLAB continue with the next line. So to comment out string2 in your function call, use ... instead of % to comment out.

With string2:

target=strcat(string, ...
              string2, ...
              'suffix' );

Without string2:

target=strcat(string, ...
              ... string2, ...
              'suffix' );
like image 101
hbaderts Avatar answered Jan 03 '26 18:01

hbaderts


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

target=strcat(string, ...
         ... string2, ...
          'suffix' ); 
like image 26
Frank Avatar answered Jan 03 '26 18:01

Frank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!