| MATLAB Function Reference | ![]() |
importdata(filename)
A = importdata(filename)
A = importdata(filename,delimiter)
A = importdata(filename,delimiter,headerline)
[A D] = importdata(...)
[A D H] = importdata(...)
[...] = importdata('-pastespecial',
...)
importdata(filename) loads data from filename into the workspace. The filename input is a string enclosed in single quotes.
A = importdata(filename) loads data from filename into structure A.
A = importdata(filename,delimiter) loads data from filename using delimiter as the column separator. The delimiter argument must be a string enclosed in single quotes. Use '\t' for tab. When importing from an ASCII file, delimiter only separates numeric data.
A = importdata(filename,delimiter,headerline) where headerline is a number that indicates on which line of the file the header text is located, loads data from line headerline+1 to the end of the file.
[A D] = importdata(...) returns the output structure in A, and the delimiter character in D.
[A D H] = importdata(...) returns the output structure in A, the delimiter character in D, and the line number of the header in H.
[...] = importdata('-pastespecial', ...) loads data from your computer's paste buffer rather than from a file.
importdata looks at the file extension to determine which helper function to use. If it can recognize the file extension, importdata calls the appropriate helper function, specifying the maximum number of output arguments. If it cannot recognize the file extension, importdata calls finfo to determine which helper function to use. If no helper function is defined for this file extension, importdata treats the file as delimited text. importdata removes from the result empty outputs returned from the helper function.
Import data from file ding.wav:
s = importdata('ding.wav')
s =
data: [11554x1 double]
fs: 22050Use importdata to read in a text file. The third input argument is colheaders, which is the number of lines that belong to the header:
type 'myfile.txt' Day1 Day2 Day3 Day4 Day5 Day6 Day7 95.01 76.21 61.54 40.57 5.79 20.28 1.53 23.11 45.65 79.19 93.55 35.29 19.87 74.68 60.68 1.85 92.18 91.69 81.32 60.38 44.51 48.60 82.14 73.82 41.03 0.99 27.22 93.18 89.13 44.47 17.63 89.36 13.89 19.88 46.60
Import from the file, specifying the space character as the delimiter and 1 row for the column header. Assign the output to variable M:
M = importdata('myfile.txt', ' ', 1);Print out columns 3 and 5, including the header for those columns:
for k=3:2:5
M.colheaders(1,k)
M.data(:,k)
disp ' '
end
ans =
'Day3'
ans =
61.5400
79.1900
92.1800
73.8200
17.6300
ans =
'Day5'
ans =
5.7900
35.2900
81.3200
0.9900
13.8900![]() | import | imread | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |