MATLAB: Import Data Tool Code

import data toolimportdatatool

Hi,
I Have been using the Import Data Tool to import data from a txt file to an array.
I want to get this operation into a code i try to use the uiimport(FileName) But i got the following error:
Error using importdata (line 228)
Unable to load file.
Use readtable for more complex formats.
Error in uiimport/runImportdata (line 531)
importdata(fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 473)
[datastruct, textDelimiter, headerLines]=
runImportdata(fileAbsolutePath, type);
Error in uiimport (line 297)
gatherFilePreviewData(fileAbsolutePath);
Caused by:
Index exceeds the number of array elements (1).
I would really appreciate your assistance,
Shany.

Best Answer

Is fileAbsolutePath the name of your text file? If so, try the following.
uiimport('fileAbsolutePath.txt')
If you want the Import Tool to generate code for importing the file based on the current settings, use the expanded options under "Import Selection". This video from our Exporatory Data Analysis with MATLAB course shows you how.
Related Question