This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Create dialog box for exporting variables to workspace


hdialog = export2wsdlg(...)
[hdialog,ok_pressed] = export2wsdlg(...)


export2wsdlg(cklabels,defaultvars,xitems) creates a dialog box with a series of check boxes and edit fields. cklabels is a cell array of labels for the check boxes. defaultvars is a cell array of default variable names that appear in the edit fields. xitems is a cell array of the values to be stored in the variables. If there is only one item to export, export2wsdlg creates a text control instead of a check box.


By default, the dialog box is modal. A modal dialog box prevents the user from interacting with other windows before responding.

export2wsdlg(cklabels,defaultvars,xitems,title) creates the dialog with title as its title.

export2wsdlg(cklabels,defaultvars,xitems,title,selected) creates the dialog allowing the user to control which check boxes are checked. selected is a logical array whose length is the same as cklabels. True indicates that the check box should initially be checked, false unchecked.

export2wsdlg(cklabels,defaultvars,xitems,title,selected,helpfcn) creates the dialog with a help button. helpfcn is a callback that displays help.

export2wsdlg(cklabels,defaultvars,xitems,title,selected,helpfcn,fcnlist) creates a dialog that enables the user to pass in fcnlist, a cell array of functions and optional arguments that calculate, then return the value to export. fcnlist should be the same length as cklabels.

hdialog = export2wsdlg(...) returns the handle of the dialog.

[hdialog,ok_pressed] = export2wsdlg(...) sets ok_pressed to true if the OK button is pressed, or false otherwise. If two return arguments are requested, hdialog is [] and the function does not return until the dialog is closed.

The user can edit the text fields to modify the default variable names. If the same name appears in multiple edit fields, export2wsdlg creates a structure using that name. It then uses the defaultvars as field names for that structure.

The lengths of cklabels, defaultvars, xitems and selected must all be equal.

The variable names in defaultvars must be unique.


This example creates a dialog box that enables the user to save the variables sumA and/or meanA to the workspace. The dialog box title is Save Sums to Workspace.

A = randn(10,1);
checkLabels = {'Save sum of A to variable named:' ...
               'Save mean of A to variable named:'}; 
varNames = {'sumA','meanA'}; 
items = {sum(A),mean(A)};
             'Save Sums to Workspace');

Was this topic helpful?