There is an API to interact with the files opened in the editor, see e.g.
matlab.desktop.editor.getAll
But how can I find the corresponding docs or further explanations? These trials are not successful in R2016b:
docsearch editor
docsearch editor api
docsearch matlab.desktop.editor
docsearch getAll
doc matlab.desktop.editor.getAll % [EDITED: This DOES work!]
doc matlab.desktop.editor % This also - See Michelle's answer
Searching in the net does not find the official documentation also, e.g. asking Google for "matlab.desktop.editor.getAll" provides these links on top:
  1. Is this API documented?
  2. If so, where do I find an exhaustive documentation?
  3. How could I find this by my own?
PS. What a pity that the powerful feature of running macros in the editor has been removed after Matlab version 5.3! FEX: EditorMacro does not work as stable as I need it.

 채택된 답변

Michelle Hirsch
Michelle Hirsch 2017년 11월 17일

1 개 추천

These functions are documented through their source code help, though there are no reference pages. Our intention is that the editor interface is fully supported.
You can use help or doc to get help on any function in the package. Doc just opens the help in the documentation browser. You can also get a listing of all of the documented functionality by calling
doc matlab.desktop.editor

댓글 수: 4

Jan
Jan 2017년 11월 17일
편집: Jan 2017년 11월 17일
@Michelle: Whoops. I did try
doc matlab.desktop.editor
help matlab.desktop.editor
in R2016b - I checked in the Command History, that I had no typo in it. I asked in the forum, because I got the "did not match any documents" and "not found" messages.
But after reading your answer I tried it again - with success. Strange. I guess a shadowed a built-in function let doc fail, but I cannot reproduce it.
Thanks for your answer. I suspected, that I have overseen a detail...
Ian
Ian 2019년 8월 25일
편집: Jan 2019년 8월 26일
Hmmm. Doc and Help matlab.desktop.editor says
"matlab.desktop.editor Summary of Editor Document functionality. Programmatically access the MATLAB Editor to open, change, save, or close documents."
But doesn't list any functions to save a file or close a file's editor window. I've tried the obvious "matlab.desktop.editor.close(...)" and "matlab.desktop.editor.closeDocument(...)" with no success. What are the functions for save and close?
Ian,
You need to extract an active instance instance and work with it.
allinstances = matlab.desktop.editor.getAll;
now examine {allinstances.FileName} to figure out which if the instances is the one that is of interest to you. Supposing it is at offset idx, then
allinstances(idx).save() or .saveAs() or .close())
LOKENDRA KUMAR AGRAWAL
LOKENDRA KUMAR AGRAWAL 2023년 8월 28일
Thanks a lots it work perfectly

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

질문:

Jan
2017년 11월 11일

댓글:

2023년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by