Why is it helpful to use regions/sections while writing a script in matlab?
7 次查看(过去 30 天)
显示 更早的评论
I was trying to make my script tidy and found out that it's possible to insert regions and sections in matlab scripts/functions. How are they correctly used? Why are they so helpful?
Thanks for your help :)
1 个评论
Adam
2017-6-23
I'm not familiar with what a 'region' is, but I pretty much never use sections. Just personal preference, but to me they confuse the reading of code rather than help it. I don't write scripts often though except for quick initial exploration of ideas and having sections in a function seems odd to me.
采纳的回答
Stephen23
2017-6-23
编辑:Stephen23
2017-6-23
Three good reasons:
- Code folding: https://www.mathworks.com/help/matlab/matlab_prog/improve-code-readability.html
- Run sections: https://www.mathworks.com/help/matlab/matlab_prog/run-sections-of-programs.html
- Because using standard tools (default indentation, code sections, etc), makes code clearer and easier to understand. Code that is clearer and easier to understand is less buggy and easier to fix.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!