Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

function to close M files

541 views
Skip to first unread message

Adam

unread,
Jul 8, 2009, 11:52:01 PM7/8/09
to
I was curious if there was a command that can close all M-files, or close the entire Editor.

It seems like it should be simple, like

close -mfile all

but I can't find anything.

Thanks!

Rune Allnor

unread,
Jul 9, 2009, 3:19:15 AM7/9/09
to sl...@mathworks.com

I agree that such functionality might be useful.
This is not a function you would want to use in an
M file, though, only as part of the GUI. I think it
would be better to include it as an option in the
EDIT menu or the pop-up menu in the editor.

Rune

Steven Lord

unread,
Jul 9, 2009, 9:12:07 AM7/9/09
to

"Rune Allnor" <all...@tele.ntnu.no> wrote in message
news:677e1670-7ac2-4bfd...@c36g2000yqn.googlegroups.com...

There are several ways to close multiple files at once or to close the
Editor. I don't believe there is a documented function that allows you to
do so, but you can use one of these methods:

1) Use the Close button in the title bar of the Editor, as described in this
section of the documentation. This will close the Editor and all documents
it contains.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-11.html#brqxeeu-22

2) Also as documented in the section I linked above, use the Window menu
items "Close Editor Documents" or "Close All Documents".

3) With the Editor active, use one of the three Close menu items in the File
menu -- "Close Editor", "Close <name of currently active file in the
Editor>" and "Close ..." which allows you to select any or all of the files
open in the editor and close the selected files.

I will enter a request for a function to close selected documents in the
Editor into our enhancement database.

--
Steve Lord
sl...@mathworks.com


Jan Simon

unread,
Jul 9, 2009, 9:13:02 AM7/9/09
to
Dear Adam!

> I was curious if there was a command that can close all M-files, or close the entire Editor.

There is an undocumented method, which might be changed with the Matlab version:
Editor = com.mathworks.mlservices.MLEditorServices;
Editor.closeAll;

For more tasks see: methods(Editor, '-full');

I do not think, it is worth to include a menu for this, because the close box of the editor window performs the tasl already.

Kind regards, Jan

Bob

unread,
Oct 10, 2011, 12:36:43 PM10/10/11
to Steven Lord
>> I was curious if there was a command that can close all M-files, or close
>> the entire Editor.
...

I will enter a request for a function to close selected documents in the
Editor into our enhancement database.
---------------


Steve

Did anything ever come of this?

Also, see my post http://tinyurl.com/3syfe9h
I am looking for a command to close all open array editor windows.

Bob

Steven_Lord

unread,
Oct 10, 2011, 2:17:02 PM10/10/11
to

"Bob" <ralv...@spambob.net> wrote in message
news:77955.724.1318264604585.JavaMail.geo-discussion-forums@prib32...


>>> I was curious if there was a command that can close all M-files, or
>>> close
>>> the entire Editor.
> ...
> I will enter a request for a function to close selected documents in the
> Editor into our enhancement database.
> ---------------
>
>
> Steve
>
> Did anything ever come of this?

http://blogs.mathworks.com/desktop/2011/05/09/r2011a-matlab-editor-api/

Use a combination of the functions findOpenDocument and/or getAll with the
close and/or closeNoPrompt methods.

> Also, see my post http://tinyurl.com/3syfe9h
> I am looking for a command to close all open array editor windows.

I'm fairly certain there isn't a documented way to do that. I recommend you
contact Technical Support and request this as an enhancement.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Brian

unread,
Apr 4, 2013, 4:27:07 PM4/4/13
to
i work on many separate projects so i often create little scripts to open sets of files.
eg: a tiny script i made years ago named 'MRI' looks like this:
>> cd('C:\Users\my_name\DATA\MRI\analysis')
>> edit('dicom_rename_and_sort_bcoev7p1')
>> edit('epi2mat');
>> edit('m3dic_v0p11o3')
>> edit('m3dic_output2_v11p2')

thanks to your message i now have a 'unMRI' script that looks like this:
>> Editor = com.mathworks.mlservices.MLEditorServices;
>> Editor.closeDocument(which('dicom_rename_and_sort_bcoev7p1.m'));
>> Editor.closeDocument(which('epi2mat'));
>> Editor.closeDocument(which('m3dic_v0p11o3'))
>> Editor.closeDocument(which('m3dic_output2_v11p2'))
>> clear Editor

if i make matching sets for my Inf other projects i can now switch between projects instantly. nice.

"Jan Simon" wrote in message <h34qcu$ih7$1...@fred.mathworks.com>...

Aditya Dua

unread,
Mar 29, 2015, 12:44:05 PM3/29/15
to
"Adam" wrote in message <h33ph1$hvq$1...@fred.mathworks.com>...
This worked for me. Tried it out on MATLAB R2015b
h = matlab.desktop.editor.getAll;
h.close

Ashish Bhatt

unread,
Mar 23, 2017, 7:26:09 AM3/23/17
to
If you are looking for a simple way rather than a command, dock an m file in matlab editor window and then close the editor. This will close all the (docked) files.


"Adam" wrote in message <h33ph1$hvq$1...@fred.mathworks.com>...
0 new messages