how to continue code in next line with comment between them

조회 수: 274(최근 30일)
i have a long line code, that i want to specify each part of code by comment in above it. i use (...) at end of each part to continue code in next this:
% line 1
% line 2
but when i write comments between lines, matlab just calculate first line. now what should i do to write comment between break lines.

채택된 답변

Stephen23 2017년 4월 30일
편집: Stephen23 2018년 1월 18일
All you need is an ellipsis on each line which continues on to another line:
a = b+c+f...
... line 2
  댓글 수: 4
John Hatrick
John Hatrick 2018년 5월 24일
편집: John Hatrick 2018년 5월 24일
Not quite as easy as ctrl-r, but I can work with it.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Andrew Newell
Andrew Newell 2017년 4월 30일
편집: Andrew Newell 2017년 4월 30일
You can have the comments beside each part instead:
a=b+c+f... % line 1
+t+h+k; % line 2
However, it is possible to over-comment code! Using meaningful names for variables is a way of making the code self-commenting.

Community Treasure Hunt

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

Start Hunting!

Translated by