Che*_*riy 7 ide matlab coding-style code-formatting
有没有类似于AStyle的工具来格式化m文件中的matlab代码?
在最新版本的MATLAB中,您可以使用MATLAB Editor API以编程方式使用"Smart Indent"工具.
例如,假设您要修复特定目录中包含的所有M文件的缩进:
%# gel list of m-files in a directory
BASE_DIR = 'c:\path\to\folder';
files = dir( fullfile(BASE_DIR,'*.m') );
files = {files.name};
for i=1:numel(files)
%# open file in editor, apply smart indentation, save and close
doc = matlab.desktop.editor.openDocument( fullfile(BASE_DIR,files{i}) );
doc.smartIndentContents;
doc.save;
doc.close;
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2361 次 |
| 最近记录: |