importdata

Returns result R after reading a file, f. Different reading mechanisms are used, based on the type of file, f.

Syntax

[R, ...] = importdata(f,...)

[R, ...] = importdata(f, options, ...)

Inputs

f
A valid file name on disk.
Type: string
options
Valid options for load, textread or xlsread. By default, textread will be used if the file cannot be read by other mechanisms.
Type: any

Outputs

R
The outputs returned will correspond to the reading mechanism used: load, textread or xlsread.
Type: any

Examples

Reads data from an Excel compatible file:
% Data in the test.xlsx is {'number','string','other';1, 'a', Nan; 2, 'b', realmax}
R = importdata('test.xlsx')
mat = [Matrix] 3 x 3
        NaN  NaN           NaN
1.00000e+00  NaN           NaN
2.00000e+00  NaN  1.79769e+308
Reads data with options available for textread:
%Data in the file is
% names of the columns A B C
% year1 100 200 300 year22 44 55 66 year333 7 8 9
[A, B, C, D] = importdata('Filemanipulation/textreadFile2.txt','%s %f %f %f','headerlines',1)
A =
{
[1,1] year1
[2,1] year22
[3,1] year333
}
B = [Matrix] 3 x 1
100
44
7
C = [Matrix] 3 x 1
200
55
8
D = [Matrix] 3 x 1
300
66
9