做网站不花钱,高品质网站欣赏,网址一键生成app免费,格泰网站建设我有同样的需求,并写了一个小脚本来做一些接近的事情.将以下内容放在MATLAB desktop shortcut中.每当您单击快捷方式按钮时,它将从编辑器中的活动文件中删除尾随空格.不如在保存时自动执行它 – 你需要记住在保存之前按下按钮 – 但差不多.测试在11b,12a和13b,但在12b也应该没问…我有同样的需求,并写了一个小脚本来做一些接近的事情.将以下内容放在MATLAB desktop shortcut中.每当您单击快捷方式按钮时,它将从编辑器中的活动文件中删除尾随空格.不如在保存时自动执行它 – 你需要记住在保存之前按下按钮 – 但差不多.测试在11b,12a和13b,但在12b也应该没问题.希望有所帮助% Temp variable for shortcut. Give it an unusual name so its unlikely to% conflict with anything in the workspace.shtcutwh__ struct;% Check that the editor is available.if ~matlab.desktop.editor.isEditorAvailablereturnend% Check that a document exists.shtcutwh__.activeDoc matlab.desktop.editor.getActive;if isempty(shtcutwh__.activeDoc)returnend% Get the current text.shtcutwh__.txt shtcutwh__.activeDoc.Text;% Remove trailing whitespace from each line.shtcutwh__.lines deblank(regexp(shtcutwh__.txt,[^\n]*(\n)|[^\n]*$, match));% Reconcatenate lines.shtcutwh__.addNewline (x)sprintf(%s\n,x);shtcutwh__.lines cellfun(shtcutwh__.addNewline, shtcutwh__.lines, UniformOutput, false);shtcutwh__.newtxt horzcat(shtcutwh__.lines{:});% Set the current text.shtcutwh__.activeDoc.Text shtcutwh__.newtxt;% Delete temp variable.clear shtcutwh__