23.12.2012 Views

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

csvread<br />

2csvread<br />

Purpose Read a comma-separated value file<br />

Syntax M = csvread('filename')<br />

M = csvread('filename',row,col)<br />

M = csvread('filename',row,col,range)<br />

Description M = csvread('filename') reads a comma-separated value formatted file,<br />

filename. The result is returned in M. The file can only contain numeric values.<br />

2-350<br />

M = csvread('filename',row,col) reads data from the comma-separated<br />

value formatted file starting at the specified row and column. The row and<br />

column arguments are zero-based, so that row=0 and col=0 specifies the first<br />

value in the file.<br />

M = csvread('filename',row,col,range) reads only the range specified.<br />

Specify the range using the notation, [R1 C1 R2 C2] where (R1,C1) is the<br />

upper-left corner of the data to be read and (R2,C2) is the lower-right corner.<br />

The range can also be specified using spreadsheet notation as in range =<br />

'A1..B7'.<br />

Remarks csvread fills empty delimited fields with zero. Data files having lines that end<br />

with a nonspace delimiter, such as a semicolon, produce a result that has an<br />

additional last column of zeros.<br />

Examples Given the file, csvlist.dat that contains the comma-separated values<br />

02, 04, 06, 08, 10, 12<br />

03, 06, 09, 12, 15, 18<br />

05, 10, 15, 20, 25, 30<br />

07, 14, 21, 28, 35, 42<br />

11, 22, 33, 44, 55, 66<br />

To read the entire file, use<br />

csvread('csvlist.dat')<br />

ans =<br />

2 4 6 8 10 12<br />

3 6 9 12 15 18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!