Documentation Center

  • Trial Software
  • Product Updates

Close MuPAD Notebooks from MATLAB

To close notebooks from the MATLAB® Command Window, use the close function and specify the handle to that notebook. For example, create the notebook with the handle nb:

nb = mupad;

Now, close the notebook:

close(nb)

If you do not have a handle to the notebook (for example, if you created it without specifying a handle or accidentally deleted the handle later), use allMuPADNotebooks to return handles to all currently open notebooks. This function returns a vector of handles. For example, create three notebooks without handles:

mupad;
mupad;
mupad;

Use allMuPADNotebooks to get a vector of handles to these notebooks:

nbhandles = allMuPADNotebooks
nbhandles = 
Notebook1
Notebook2
Notebook3

Close the first notebook (Notebook1):

close(nbhandles(1))

Close all notebooks:

close(allMuPADNotebooks)

If you modify a notebook and then try to close it, MuPAD® brings up the dialog box asking if you want to save changes. To suppress this dialog box, call close with the 'force' flag. You might want to use this flag if your task requires opening many notebooks, evaluating them, and then closing them. For example, suppose that you want to evaluate the notebooks myFile1.mn, myFile2.mn, ..., myFile10.mn located in your current folder. First, open the notebooks. If you do not have any other notebooks open, you can skip specifying the handles and later use allMuPADNotebooks. Otherwise, do not forget to specify the handles.

mupad('myFile1.mn');
mupad('myFile2.mn');
...
mupad('myFile10.mn');

Evaluate all notebooks:

evaluateMuPADNotebook(allMuPADNotebooks);

When you evaluate MuPAD notebooks, you also modify them. Therefore, when you try to close them, the dialog box asking you to save changes will appear for each notebook. To suppress the dialog box and discard changes, use the 'force' flag:

close(allMuPADNotebooks,'force')
Was this topic helpful?