How do I comment out a large block of code in MATLAB?
3,900 次查看(过去 30 天)
显示 更早的评论
I want to do this in an easy way.
3 个评论
采纳的回答
Doug Hull
2011-1-18
编辑:MathWorks Support Team
2018-11-8
5 个评论
Shapol Mohamed
2021-3-18
In Matlab 2020, you have to use ctrl+/ (cmd+/ for mac) to comment a block and to uncomment you have to use ctrl+t (cmd+t for mac).
更多回答(3 个)
CHUANQIANG ZHANG
2018-5-10
Ctrl + R comment selected lines. Ctrl + T uncomment select lines.
https://stackoverflow.com/questions/30925796/is-there-a-shortcut-key-to-comment-multiple-lines-in-matlab-editor/30926004#30926004
0 个评论
Wesam Rezk
2018-3-30
Simply start with *... and write whatever you want. This will enable you to write a very long comment line
For example *... This is a very very long comment
0 个评论
Wick
2018-5-1
编辑:Wick
2018-5-1
Rather than comment large sections of code, I bypass them with the following syntax.
for dont_go_here = []
% code I want to skip including all nested comments, etc. can stay here unmolested
end
This assumes that your if, for, case, try, and switch commands within that block are all terminated properly with an 'end' Otherwise the script won't parse.
另请参阅
类别
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!