| Contents | Index |
The Variable Editor enables you to:
Display variables in the current workspace.
View and edit values of one or two-dimensional arrays, character strings, cell arrays, structures, and objects and their properties.
View the contents of multidimensional arrays.
Copy and paste data values.
Edits you make in the Variable Editor immediately update the variable in the workspace.
To open the Variable Editor from the Workspace browser, perform these steps:
If you do not have any, create some workspace variables, for example:
A = magic(4);
x = 0:.1:4*pi;
y = sin(x);
s = sprintf('This is yext\nwith two lines');If the Workspace browser is not open, select Desktop > Workspace.
In the Workspace browser, select the variable you want to open. Use Shift+click or Ctrl+click to select multiple variables, or use Ctrl+A to select all variables to open.
Click the Open Selection
button
on the toolbar. For one
variable, you can also open it by double-clicking it.
The Variable Editor opens, displaying the values for the selected variable. The class and size of the value appear below the toolbar, and for some classes, include a link to the help for that class.

Click the Plot Selector to create a graph of the selected variables.
Click a tabbed document to display a different variable that is open in the Variable Editor.
Changes you make to variables via the Command Window or other operations automatically update the information for those variables in the Variable Editor.
To open a variable in the Variable Editor, use openvar with the name of the variable you want to open as the argument. For example, type
openvar('A')
To see the contents of a variable in the workspace, type the variable name at the Command Window prompt. For example, type:
A
MATLAB returns:
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1To view and edit the content of cell arrays in the Variable
Editor, double-click a cell array element. It opens it a new Variable
Editor document. You can then view and edit the contents of that element.
The following illustrations show a 1-by-3 cell array, C, and the contents of C{1,1}.
When viewing an element in a cell array, for example, C{1,1}, use the Up button
to go to its cell array,
for this example, C.


To view and edit the content of a structure currently displaying in the Variable Editor, following the procedure exemplified here:
Create a structure by running the following code in the Command Window:
S.name = 'Ed Plum' S.score = 83; S.grade = 'B+' S(2).name = 'Toni Miller'; S(2).score = 91; S(2).grade = 'A-'; S(3).name = 'Bill Cox'; S(2).score = 92; S(3).grade = 'A-'; S(3).score = 92; S(2).score = 91;
Open S in the Variable Editor by double-clicking S in the Workspace Browser.
The Variable Editor opens and displays S.

Display S(1,2), by double-clicking the element in row 1, column 2.
A new Variable Editor document opens and displays S(1,2).

Edit the value for the grade field by right-clicking the value, and then select Edit Value from the context menu.
Adjust the columns in the structure element document:
Sort columns by clicking a column header. Click the header again to reverse the sort order.
Show or hide columns by right-clicking any column header, and then, selecting or deselecting column header names, respectively. (This feature is available on Microsoft Windows platforms only.)
Return to the structure document by clicking the Up button
.
Viewing Object Properties in the Variable Editor. In the Variable Editor, you can view and edit properties of many MATLAB objects you create.
When you open an object in the Variable Editor, it displays Property, Value, Size, and other information. To:
Show or hide a column, right-click the column header.
Sort by a column, click that column header; to reverse the sort order, click the column header again.
View help for the class, click the class name link.
The Variable Editor has special attributes for timeseries objects; for more information, see Viewing Time Series Objects.
The following illustration shows the sensorArray object of the sads class, in the Variable Editor. For more information about this example, see Example of Help for a Externally Supplied Class.

Lock icons, which can appear during debugging, denote protected
and private
properties of an object, indicating
you do not have get access to those values outside
class methods. The following illustration shows an object, resident. The Town property
is protected and the State property
is private. An attempt to get the State property
programmatically returns the error, Getting the 'State' property
of the 'Test' class is not allowed.

Editing Property Values in the Variable Editor. To edit a property value while viewing the object, click the value field and then edit its contents. To more easily view a value before editing, double-click the value to display it in its own document, and then edit it.
When viewing a property, use the Up button
to view the object. This
button can help you navigate in the Variable Editor when there are
many variables open.
If the Variable Editor window is small, the Up button might not be visible. To access it, click the >> button on the right side of the toolbar, and then select Go Up One Level from the menu.
Getting Help for Objects and Properties from the Variable Editor. For most classes supplied by The MathWorks®, when you click the link to the class name, for example, char, the reference page displays in the Help browser. For user-created classes, help comments supplied in the class definition file display in HTML format in the Help browser. For more information, see Help for Classes You Create.
You can view the contents of multidimensional arrays in the Variable Editor. When you open a multidimensional array in the Variable Editor, it does not have the usual grid structure, because multidimensional arrays do not fit that format. You cannot double-click an element in a multidimensional array to edit it. The following illustration shows R = rand(3,4,5) open in the Variable Editor.

You can view subsets of multidimensional arrays as long as the indexing expression evaluates to either a 1-D vector or a 2-D matrix. For example, R(2,:,:) , R(:,2,:), and R(:,:,2) display as follows.
|
|
|
You cannot edit subsets of multidimensional matrices. Because you can index into matrices in so many ways, the Variable Editor can incorrectly identify subscripts of variable elements that you might change. To avoid changing the wrong data elements, the Variable Editor prevents you from editing multidimensional matrices.
To move among elements in the Variable Editor, use the following shortcut keys (sometimes called hot keys). Navigating in the Variable Editor is much like navigating in the Microsoft Excel application. You cannot modify these keyboard shortcuts. For information on additional Variable Editor keyboard shortcuts (which you can modify), see Keyboard Shortcuts.
To: | Press this Key: |
|---|---|
Commit changes to an element and move to next element. Variable Editor Preferences enable you to specify what the next element is (the default is down). | Enter |
Move right. Within a selection, also moves from the last column to the first column in the next row. | Tab |
Move in opposite direction of Enter or Tab. | Shift+Enter or Shift+Tab |
Move up m rows, where m is the number of visible rows. | Page Up |
Move down m rows, where m is the number of visible rows. | Page Down |
Move to column 1. | Home |
Move to row 1, column 1. | Ctrl+Home |
Move to last column in current row. | End |
Edit current element, positioning cursor at the end of the element. | F2 (Ctrl+U on Apple Macintosh platforms) |
| To: | Do This: |
|---|---|
Increase the size of an array. | Scroll to the desired element in the variable and enter a value. Empty elements fill with zeros if numeric, or empty arrays if a cell array. |
Decrease the size of an array. |
|
Change the value of an element. |
|
Specify where the cursor moves to after you press Enter. | Select File > Preferences > Variable Editor, and then select Editing options:
|
Change the display format. | From the View menu, select a format. |
Change the default format. | Select File > Preferences > Variable Editor, and then select a Format option. |
Make MAT-file changes permanent. |
You can cut, copy, paste, insert, or delete selected elements, rows, and columns in an array, as described in the following table.
| To: | Do This: |
|---|---|
Select a column or row. | Click the row or column header (the element that shows the row or column number). |
Select contiguous elements, rows, or columns in an array. | Click the header of the first row, and then Shift+click additional rows. |
Select all elements. | Select Edit > Select All. |
Cut selected elements. | Select Edit > Cut or click the Cut button
The value of each element you cut becomes 0 if numeric or [] if a cell array. The cut values move to the clipboard. |
Copy selected elements. | Select Edit > Copy or click the Copy button
|
Paste cut or copied elements into selected elements. | Select Edit > Paste or click the Paste button
If the shape of the elements you cut or copy differs from the shape of the elements into which you are pasting, the Variable Editor pastes all the elements. Either the Variable Editor expands the size of the selection you made, or it expands the array size to allow all the elements you are pasting. |
Insert elements, rows, and columns in arrays. |
If you insert an entire row or column, the Insert dialog box does not open. MATLAB inserts a row above the select row or a column to the right of the selected column. |
Delete elements, rows, and columns in arrays. |
If you delete an entire row or column, the Delete dialog box does not open. MATLAB shifts columns or rows to replace the deleted column or row. |
Undo the last operation. | Select Edit > Undo, or click the desktop toolbar Undo button. |
Redo the last operation. | Select Edit > Redo, or click the desktop toolbar Redo button. |
Set the value of elements to 0. | Select elements, rows, or columns for which you want to set the value to 0, and then select Edit > Clear Contents. |
In this example, you copy two elements. When you select one element for pasting, it replaces two elements.
Create a matrix variable.
A = magic(4);
In the Workspace Browser, double-click A.
In the Variable Editor, select and copy these two elements from rows 3 and 4:
Click 7 (A(3,2)) and then Shift+click 14 (A(4,2)).
Right-click the selection, and then select Copy from the context menu.
Select 9 (A(3,1)), right-click, and then select Paste from the context menu.
The column vector you copied ([7;14]) replaces the contents of rows 3 and 4 in column 1 (which had been [9,4]), even though you only selected the element containing 9. That is, the shape of the copied elements determines which values get replaced, starting at the upper left element.

In this example, you cut two rows and paste them into a single row. The Variable Editor expands the array size, adding a row to accommodate all pasted elements. The values of the elements you cut become 0.
Create a matrix variable.
A = magic(4);
In the Workspace Browser, double-click A.
In the Variable Editor, select rows 2 and 3:
Click row number 2, and then Shift+click row number 3.
Right-click the selection and select Cut from the context menu.
The values in the cut rows all become 0 as a result of the cut operation.
Select row number 4, and then right-click and select Paste from the context menu. The contents of the cut rows replace row 4 and extend the matrix to one additional row.

You can exchange Variable Editor data with other desktop tools and external applications if the data types are compatible. For example, you cannot paste text from the Command Window or an Microsoft Excel spreadsheet into a numeric array in the Variable Editor.
Tip If you cut and paste Variable Editor values into text files or other applications, you can change the character that delimits decimals in the data that is exported. You might do this, for instance, if you provide data to a locale that uses a character other than the period (.). Select File > Preferences > Variable Editor, and then change the character for Decimal separator for exporting numeric data via system clipboard. |
To exchange data with the Command Window, do either of the following:
Copy data from an array in the Variable Editor and paste it into the Command Window.
Copy a value from the Command Window and paste it into an element in the Variable Editor.
To create new workspace variables from the Variable Editor:
Select an element, data range, row, or column in an array in the Variable Editor.
Right-click, and then from the context menu, select Create Variable from Selection.
To exchange data with a Microsoft Excel spreadsheet, do either of the following:
In the Microsoft Excel application, cut or copy cells, and then in the Variable Editor, select Edit > Paste from Excel
Cut or copy elements from an array in the Variable Editor and paste them into the Microsoft Excel application
The Variable Editor, like the Workspace Browser, provides several methods for creating graphs without typing plotting commands. Once a graph displays, you can "brush" either the graph or array elements in the Variable Editor to see which observations correspond in the other.
You can create graphs from selected variables in the Variable Editor. To create a graph, select a data range, row, or column in an array, and choose a graph type in one of the ways described in the following bullets. MATLAB examines the selected data and determines which kinds of graphs can display it. In some cases, MATLAB performs data conversion, such as using cell2mat to transform cell array data—which cannot be plotted directly—to matrix data.
You can graph selections of numeric data and selected objects from the Variable Editor in three ways, illustrated here:
Select data, and then choose from a list of graph types from the Graphics menu.

Select data, and then right-click, and choose from a list of graph types from the context menu.
The types of graphs available on the context menu and the Graphics menu are the same.
Select data, and then click the Plot Selector toolbar
button
to generate
the type of plot it displays.
Assuming that you select the same graph type, all three methods generate identical plots of the selected data in the current or a new figure window.

The Plot Selector is the most flexible of the three methods. It lists more graph types that you can currently make and, in a separate tab, all graph types available to you. It also provides function help, and lets you prioritize graph types as a list of favorites. The following illustration compares it to the Graphics menu.

For more information about using the Plot Selector, see Creating Plots from the Workspace Browser.
Data brushing is a technique for exploring where specific data
observations fall in a set of graphs and tables. It helps you to visually
identify relationships, outliers, trends, and noise that can be difficult
to determine with numerical or statistical methods. Use the Data Brushing
Tool
on
the Variable Editor and figure toolbars to mark specific observations
(or ranges of them) in the Variable Editor and on graphs. You can
remove brushed observations or save them to new variables.
If a variable you brush in the Variable Editor is plotted on
a graph, selecting the Data Brushing tool and brushing array elements
in the Variable Editor highlights those values in the graph displaying
the variable you brush. Likewise, brushing observations on a linked
plot highlights them in the Variable Editor. For data brush to communicate
between the two windows, the figure must be in Linked Plot
mode.
Linked Plot mode connects a graph's XData, YData and ZData to
its data sources in the current workspace. For more information, see Data Brushing with the Variable Editor and
the reference pages for brush and linkdata.
![]() | MATLAB Workspace Browser | Workspace Browser and Variable Editor Preferences | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |