how to count uncommented ligns in matlab file?
Show older comments
Hi,
I would like to count the number of ligns of code I produced for a project.
But I don't want to count commented ligns in the file. Otherwise I know I can use the function suggested (here).
Moreover sometimes the first character is not the (%) and there are some blank spaces before
Does anyone have an idea?
Thanks a lot.
Accepted Answer
More Answers (1)
Image Analyst
on 2 Apr 2023
0 votes
You can use my comment counter program, attached.
3 Comments
Adam Danz
on 2 Apr 2023
Would this be a good candidate for the file exchange (I haven't looked at it yet)?
There's still this thing that I built off comment_counter.m to add support for legacy versions and some other features.
This all comes from a conversation here:
thispath = fullfile(matlabroot,'toolbox/images/colorspaces/');
checkcomments('path',thispath,'direction','ascend','countblank','recursive')
Rik gets credit for the core code that actually finds the comments. If all one needs to do is isolate comments from non-comments, then that's really what they need. See checkcommProcessor() and Rik's minify code on the FEX.
Adam Danz
on 3 Apr 2023
Wow, that looks useful!
Categories
Find more on Reinforcement Learning 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!