Cleaning-up Code With Comments
조회 수: 6 (최근 30일)
이전 댓글 표시
I remember there was a command to add tildes to the end of a line of comments so as to distinguish it more from the actual code. I think I was using 2009b at the time and now I'm using 2007b. Was I hallucinating?
댓글 수: 0
답변 (5개)
bym
2013년 4월 9일
%{
were you thinking
of multiple
lines of
comments? (curly
braces,not tildes)
}%
댓글 수: 0
Mahdi
2013년 4월 9일
To add comments into a code, simply use the percent (%) sign. For example
for i=1:10
x=i % Makes x equal to i
end
댓글 수: 0
Razvan
2013년 4월 9일
Control + R comments a line and Control + T removes the comment marker from the begining of a line. The comments start with the percent sign %. I have no idea in which version of Matlab these shortcuts were introduced...
댓글 수: 0
Image Analyst
2013년 4월 9일
Tildes mean to ignore certain return arguments:
[folder, ~, ~] = fileparts(mfilename('fullpath'))
which doesn't return anything for the base filename, or the extension. Introduced somewhat recently.
Percent symbol means the rest of the line after the percent symbol is to be considered as a comment. Can be at the start of a line of text, on the line after the code statement is done.
% This is a comment on it's own line.
magic(4) % This is a comment after a line of code.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!