Does Matlab have the function to format script?
Ältere Kommentare anzeigen
Just wondering if Matlab has the function to format script, e.g., automatically add a space after a comma, or add spaces before and after an "=" when I press semicolon at the end of a statement, or select a block of script to be formatted and press some button. Thanks.
Akzeptierte Antwort
Weitere Antworten (4)
Azzi Abdelmalek
am 10 Jun. 2016
14 Stimmen
Select your code, then right click with your mouse, you will see all possibilities you have. For example (ctrl+i) which is smart indent
Image Analyst
am 8 Jan. 2022
6 Stimmen
Type
control-a, to select all text in your editor window, then
control-i, to fix (properly align) the indenting of your lines of code.
1 Kommentar
oren montgomery
am 28 Aug. 2022
Bearbeitet: Walter Roberson
am 28 Aug. 2022
I made this tool a while back https://www.mathworks.com/matlabcentral/fileexchange/101604-automated-code-organizer?s_tid=srchtitle
Its smiliar to ctrl+i but as a few more functions
Florian Schanda
am 13 Apr. 2021
Bearbeitet: Walter Roberson
am 13 Apr. 2021
0 Stimmen
Julian Hapke
am 11 Dez. 2023
Here's a MATLAB snippet that depends on the undocumented tree2str and mtree, but produces a reasonable result:
tree2str(mtree(FILENAME, '-file', '-comments'))
Kategorien
Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!