I have wrote a function that writes other functions. I want to now apply smart indent to the file to improve the aesthetics of the created function by aligning if_ends,etc. How can I do this programmaticly instead of the usual 'right-click' and select method as if programming manaually.

 채택된 답변

Oleg Komarov
Oleg Komarov 2011년 7월 12일
편집: Oleg Komarov 2015년 12월 7일
Suppose you have this fcn saved as foo:
function l = foo()
for l = 1:10
l
for l
l = 1:10
end
end
Then using editor API:
h = matlab.desktop.editor.openDocument('C:\Users\Oleg\Desktop\foo.m');
h.smartIndentContents
h.save
h.close

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

질문:

2011년 7월 12일

댓글:

2025년 12월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by