How do I comment out a large block of code in MATLAB?
Show older comments
I want to do this in an easy way.
3 Comments
Carol Hurwitz
on 8 Jul 2018
CTRL+R
Hamid Nourani
on 21 Apr 2020
Great
Md.Al AMIN TALUKDER
on 26 Jul 2020
ctrl+r
u can use both for single or multiple line.
Accepted Answer
More Answers (3)
CHUANQIANG ZHANG
on 10 May 2018
15 votes
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
3 Comments
Sainyam Gupta
on 15 Jun 2023
you are making us fool bc
ctrl+t open new tab.....mf
Manik Sharma
on 15 Jun 2023
Ctrl+t opens new tab bc.
Steven Lord
on 15 Jun 2023
Search the list of keyboard shortcuts for the word "comment" or for the key combination Ctrl+T and you should see the actions associated with commenting out code or that will be performed in various components of the MATLAB Desktop in the keyboard shortcut set you've told MATLAB to use.
In my MATLAB installation using the Windows keyboard shortcut set, Ctrl+T creates a new tab in the Help Browser but uncomments code when used in the Editor.
Wesam Rezk
on 30 Mar 2018
2 votes
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
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.
1 Comment
THONTI BEERAIAH
on 18 Jan 2023
Thank you, this is what I need.
Categories
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!