14 Examples of UIs Created Programmatically
Import Data into List Master
You can import data into the UI at any time. If the UI already contains data, the data
you import replaces it.
You can import data from a cell array in the MATLAB workspace. Each element of the
cell array must contain a line of text corresponding to a single list item. For example, you
can define a list of grocery items as follows:
groceries = {'1 dozen large eggs';
'1/2 gallon milk';
'5 lb whole wheat flour';
'1 qt. vanilla ice cream';};
If you load the example MAT-file senators110cong.matand display it in the Variables
editor, you can see it is structured this way.
Use spaces as separators between words in lists. If a list contains tab characters, the list
box does not display them.
As it exists, you cannot import data from a text file using the List Master example code
as supplied. It does contain a commented-out File menu item for this purpose and a
callback for it (lmfileimport) containing no code. See “Add an “Import from File”
Option to List Master” on page 14-31 for more information.
You do not need to import data to work with List Master. The UI allows you to create
lists by selecting the Add radio button, typing items in the edit text box one at a time,
and pressing Return to add each one to the list. You can export any list you create.
Export Data from List Master
To export the current list as a cell array, select File > Export list > to workspace. The
lmwsexport function calls the assignin function to create the variable after you specify
its name. If you only want to export a single list item, perform these steps:
1 Click on the list box item you want to copy or select the item's text in the edit box.
2 Type Ctrl+C to copy the item.
3 Open a document into which you want to paste the item
4 Place the cursor where you want to paste the item and type Ctrl+V.
You cannot paste from the system clipboard into the list box, because the content of a list
box can only be changed programmatically, by setting its String property. This means