Import data interactively into MATLAB® workspace.
For information on importing text files, see Read Text File Data Using Import Tool. For information on importing spreadsheets, see Read Spreadsheet Data Using Import Tool. For information on importing HDF4 files, see Import HDF4 Files Interactively.
Start the Import Wizard by selecting Import Data
To view images or video, or to listen to audio, click the Back button on the first window that the Import Wizard displays.
The right pane of the new window includes a preview tab. Click the button in the preview tab to show an image or to play audio or video.
The Import Wizard generates default variable names based on the format and content of your data. You can change the variables in any of the following ways:
The default variable name for data imported from the system clipboard is
If the Import Wizard detects a single variable in a file, the default variable
name is the file name. Otherwise, the Import Wizard uses default variable names that
correspond to the output fields of the
importdata function. For
more information on the output fields, see the
importdata function reference
To override the default variable name, select the name and type a new one.
To avoid importing a particular variable, clear the check box in the Import column.
To import data into fields of a structure array rather than as individual
variables, start the Import Wizard by calling
uiimport with an output
argument. For example, the sample file
map. If you issue the command
durerStruct = uiimport('durer.mat')
and click the Finish button, the Import Wizard returns a scalar structure with three fields:
durerStruct = X: [648x509 double] map: [128x3 double] caption: [2x28 char]
To access a particular field, use dot notation. For example, view the
Albrecht Durer's Melancolia. Can you find the matrix?
For more information, see Access Data in Structure Array.
To create a function that reads similar files without restarting the Import
Wizard, select the Generate MATLAB code check box. When you
click Finish to complete the initial import operation,
MATLAB opens an Editor window that contains an unsaved function. The default
function name is
N is an integer.
The function in the generated code includes the following features:
For text files, if you request vectors from rows or columns, the generated code also returns vectors.
When importing from files, the function includes an input argument for the
name of the file to import,
When importing into a structure array, the function includes an output
argument for the name of the structure,
However, the generated code has the following limitations:
If you rename or deselect any variables in the Import Wizard, the generated code does not reflect those changes.
If you do not import into a structure array, the generated function
creates variables in the base workspace. If you plan to call the generated
function from within your own function, your function cannot access these
variables. To allow your function to access the data, start the Import
Wizard by calling
uiimport with an output
argument. Call the generated function with an output argument to create a
structure array in the workspace of your function.
MATLAB does not automatically save the function. To save the file, select
Save. For best results, use the function name with a
.m extension for the file name.