Effacer les filtres
Effacer les filtres

How to close .m script file in GUI with a push button?

1 vue (au cours des 30 derniers jours)
OK
OK le 19 Août 2019
Commenté : OK le 20 Août 2019
How to close .m script file in GUI with a push button?

Réponse acceptée

Walter Roberson
Walter Roberson le 20 Août 2019
Modifié(e) : Walter Roberson le 20 Août 2019
allEditors = matlab.desktop.editor.getAll;
Now match the filename you want to close against {allEditors.Filename} to figure out the index of the session you want to close. For example,
filenames = regexp({allEditors.Filename}, '[^/\\]+$', 'match','once');
[found, idx] = ismember(FilenameToClose, filenames);
if found
allEditors(idx).close();
end
Except that you need to be more careful than this because there can be multiple files with the same last part of the file name, distinguished by directory.
  1 commentaire
OK
OK le 20 Août 2019
Nice, it worked well. Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by